Init
This commit is contained in:
50
ACMOJ-1954.cpp
Normal file
50
ACMOJ-1954.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include<iostream>
|
||||
#include<cstring>
|
||||
#include<algorithm>
|
||||
#include<cassert>
|
||||
using namespace std;
|
||||
typedef long long LL;
|
||||
const int maxm=2e5+10;
|
||||
struct Node
|
||||
{
|
||||
int SubNode[2];
|
||||
int Cnt[4];
|
||||
}buf[maxm*50]; int NodeCnt=1,Root=1;
|
||||
void AddPair(LL x,LL y,int v)
|
||||
{
|
||||
const LL XorValue=x^y;
|
||||
int p=Root;
|
||||
for(int i=60;i>=0;i--)
|
||||
{
|
||||
if(buf[p].SubNode[(XorValue>>i)&1]==0) buf[p].SubNode[(XorValue>>i)&1]=++NodeCnt;
|
||||
buf[p].Cnt[(((x>>i)&1)<<1)+((y>>i)&1)]+=v;
|
||||
p=buf[p].SubNode[(XorValue>>i)&1];
|
||||
}
|
||||
}
|
||||
int query(LL x,LL y)
|
||||
{
|
||||
const LL XorValue=x^y;
|
||||
int res=0,p=Root;
|
||||
for(int i=60;i>=0;i--)
|
||||
{
|
||||
if(p==0) break;
|
||||
res+=buf[p].Cnt[((((x>>i)&1)^1)<<1)+((y>>i)&1)];
|
||||
p=buf[p].SubNode[(XorValue>>i)&1];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
#ifdef local
|
||||
freopen("pro.in","r",stdin);
|
||||
#endif
|
||||
int M; scanf("%d",&M);
|
||||
for(int i=1;i<=M;i++)
|
||||
{
|
||||
int op; LL x,y; scanf("%d%lld%lld",&op,&x,&y);
|
||||
if(op==1) AddPair(x,y,1);
|
||||
else if(op==2) AddPair(x,y,-1);
|
||||
else printf("%d\n",query(x,y));
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user