#include<bits/stdc++.h>
#define il inline
#define ui unsigned int
#define ll long long
#define ull unsigned ll
#define lll __int128
#define db double
#define ldb long double
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define fir first
#define sec second
#define gc getchar
#define pc putchar
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pct __builtin_popcount
#define mst(a,x) memset(a,x,sizeof a)
#define mcp(a,b) memcpy(a,b,sizeof b)
using namespace std;
const int N=1+10,NN=1e8+10,INF=0x3f3f3f3f,MOD=998244353,M=6666679,MM=440305;
const ll INFll=0x3f3f3f3f3f3f3f3f;
il int rd() {int x=0,f=1; char ch=gc(); while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=gc();} while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=gc(); return x*f;}
il ll rdll() {ll x=0; int f=1; char ch=gc(); while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=gc();} while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=gc(); return x*f;}
il void wr(int x) {if(x==INT_MIN) return printf("-2147483648"),void(); if(x<0) return pc('-'),wr(-x); if(x<10) return pc(x+'0'),void(); wr(x/10),pc(x%10+'0');}
il void wrll(ll x) {if(x==LLONG_MIN) return printf("-9223372036854775808"),void(); if(x<0) return pc('-'),wrll(-x); if(x<10) return pc(x+'0'),void(); wrll(x/10),pc(x%10+'0');}
il void wr(int x,const char *s) {wr(x),printf("%s",s);}
il void wrll(ll x,const char *s) {wrll(x),printf("%s",s);}
il int vmod(int x) {return x>=MOD?x-MOD:x;}
il int vadd(int x,int y) {return vmod(x+y);}
il int vsub(int x,int y) {return vmod(x-y+MOD);}
il int vmul(int x,int y) {return 1ll*x*y%MOD;}
il int qpow(int x,int y) {int r=1; for(;y;y>>=1,x=vmul(x,x)) if(y&1) r=vmul(r,x); return r;}
il void cadd(int &x,int y) {x=vmod(x+y);}
il void csub(int &x,int y) {x=vmod(x-y+MOD);}
il void cmul(int &x,int y) {x=vmul(x,y);}
il void cmax(int &x,int y) {x<y&&(x=y);}
il void cmaxll(ll &x,ll y) {x<y&&(x=y);}
il void cmin(int &x,int y) {x>y&&(x=y);}
il void cminll(ll &x,ll y) {x>y&&(x=y);}
int n,m; ll as;
il ll sz(ll u) {return (1ll<<n-__lg(u))-1;}
#define pli pair<ll,int>
#define pll pair<ll,ll>
struct HSH {
vector<pli> h[M];
// bool a[NN];
int count(ull u) {
// if(u<NN) return a[u];
u^=u<<19,u^=u>>26,u^=u>>8,u^=u<<17;
for(auto [k,v]:h[u%M]) if(k==u) return 1;
return 0;
}
void upd(ull u,int v) {
// if(u<NN) return a[u]+=v,void();
u^=u<<19,u^=u>>26,u^=u>>8,u^=u<<17;
for(auto &[k,_v]:h[u%M]) if(k==u) return _v+=v,void();
h[u%M].pb({u,v});
}
} bk;
struct hsh {
vector<pli> h[MM];
// bool a[NN];
int count(ull u) {
// if(u<NN) return a[u];
u^=u<<19,u^=u>>26,u^=u>>8,u^=u<<17;
for(auto [k,v]:h[u%MM]) if(k==u) return 1;
return 0;
}
void upd(ull u,int v) {
// if(u<NN) return a[u]+=v,void();
u^=u<<19,u^=u>>26,u^=u>>8,u^=u<<17;
// for(auto &[k,_v]:h[u%M]) if(k==u) return _v+=v,void();
h[u%MM].pb({u,v});
}
} vs;
struct _HSH {
vector<pll> h[M];
ll a[N];
ll qry(ull u) {
if(u<N) return a[u];
u^=u<<19,u^=u>>26,u^=u>>8,u^=u<<17;
for(auto [k,v]:h[u%M]) if(k==u) return v;
return 0;
}
void upd(ull u,ll v) {
if(!vs.count(u)) return;
if(u<N) return a[u]+=v,void();
u^=u<<19,u^=u>>26,u^=u>>8,u^=u<<17;
for(auto &[k,_v]:h[u%M]) if(k==u) return _v+=v,void();
h[u%M].pb({u,v});
}
} ct;
const int Q=3e5+10;
int oo[Q]; ll uu[Q];
void QwQ() {
n=rd(),m=rd();
vs.upd(1,1);
for(int i=1;i<=m;i++) {
oo[i]=rd(),uu[i]=rdll();
if(oo[i]==1&&!vs.count(uu[i])) vs.upd(uu[i],1);
}
for(int i=1;i<=m;i++) {
int o=oo[i]; ll u=uu[i];
if(o==1) {
if(bk.count(u)) continue;
bk.upd(u,1); ll x=sz(u),y=ct.qry(u);
for(ll v=u>>1,nv=u;v&&(nv==u||!bk.count(nv));v>>=1) ct.upd(v,x-y),nv=v;
} else {
ll v=u;
for(;v>1&&!bk.count(v);v>>=1);
as^=sz(v)-ct.qry(v);
// wr(v," "),wr(as,"\n");
}
}
wrll(as,"\n");
}
signed main() {
// freopen("in.in","r",stdin),freopen("out.out","w",stdout);
int T=1; while(T--) QwQ();
}剪贴板
剪贴板 tdupzuv5
剪贴板信息
剪贴板信息
- 收录
- 更新