You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
628 B
41 lines
628 B
#include<iostream>
|
|
#include<bits/stdc++.h>
|
|
using namespace std;
|
|
int add(int a,int b)
|
|
{
|
|
int sum=0;
|
|
if(a+3<=b)
|
|
sum++;
|
|
if(a-3>=1)
|
|
sum++;
|
|
return sum+1;
|
|
}
|
|
int cdd(int a,int b)
|
|
{
|
|
int sum=0;
|
|
if(a+3<=b)
|
|
sum--;
|
|
if(a-3>=1)
|
|
sum--;
|
|
return sum-1;
|
|
}
|
|
int main()
|
|
{
|
|
int m,q,op,num,sum=0;
|
|
cin>>m>>q;
|
|
for(int i=0;i<q;i++)
|
|
{
|
|
cin>>op>>num;
|
|
if(op==1)
|
|
{
|
|
sum+=add(num,m);
|
|
}
|
|
if(op==2)
|
|
{
|
|
sum+=cdd(num,m);
|
|
}
|
|
cout<<sum<<endl;
|
|
}
|
|
return 0;
|
|
}
|