#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> bool maximize(T &a, const T &b){ return (a < b ? a = b, 1 : 0); }
template<class T> bool minimize(T &a, const T &b){ return (a > b ? a = b, 1 : 0); }
#define fi first
#define se second
#define pb push_back
#define ii pair<int, int>
#define all(x) x.begin(), x.end()
#define TASK "nonsense"
/// end of template ///
const int mb = 6;
bool state[2][(1<<mb)+1];
int n,q;
int cal(int l1, int r1, int l2, int r2)
{
bool ok1=1;
for(int i=l1+1;i<=r1;++i) ok1&=(state[0][i]==state[0][i-1]);
bool ok2=1;
for(int i=l2+1;i<=r2;++i) ok2&=(state[1][i]==state[1][i-1]);
if(ok1 && ok2) return 1;
int ans=1;
int mid1((l1+r1)>>1);
int mid2((l2+r2)>>1);
ans+=cal(l1,mid1,l2,mid2);
ans+=cal(mid1+1,r1,l2,mid2);
ans+=cal(l1,mid1,mid2+1,r2);
ans+=cal(mid1+1,r1,mid2+1,r2);
return ans;
}
void solve()
{
cin>>n>>q;
if(n>6 || q>128) return cout<<"WTF",void();
while(q--)
{
bool gogo; cin>>gogo;
int x; cin>>x;
state[gogo][x]^=1;
cout<<cal(1,1<<n,1,1<<n)<<'\n';
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen(TASK".inp","r",stdin);
// freopen(TASK".ans","w",stdout);
int testcase=1;
// cin>>testcase;
while (testcase--)
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |