Pagini recente » Cod sursa (job #458153) | Cod sursa (job #2744024) | Cod sursa (job #720019) | Cod sursa (job #2890600) | Cod sursa (job #966825)
Cod sursa(job #966825)
#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <ctime>
#include <string>
#include <algorithm>
using namespace std;
ifstream ff("hashuri.in");
ofstream gg("hashuri.out");
#define md 19007
vector<int> cc[32][md];
int hh[32][md];
int bit(int x){
int n=0;
while(x>0){n++; x-=x&-x;}
return n;
}
bool eok(int k,int p, int x){
int l=hh[k][p];
for(int i=0;i<l;i++)
if(cc[k][p][i]==x)return 1;
return 0;
}
void add(int k,int p, int x){
int l=hh[k][p];
for(int i=0;i<l;i++)
if(cc[k][p][i]==x)return;
if(l<cc[k][p].size()) cc[k][p][ hh[k][p]++ ]=x; else {
cc[k][p].push_back(x);
hh[k][p]++;
}
}
void rem(int k,int p,int x){
int l=hh[k][p];
for(int i=0;i<l;i++)
if(cc[k][p][i]==x){
cc[k][p][i]=cc[k][p][ --hh[k][p] ];
return;
}
}
int main(){
int n, op, x, k, p;
ff >> n;
for(int i=1;i<=n;i++){
ff >> op >> x;
k=bit(x);
p=x%md;
if(op==1){ add(k,p,x); } else
if(op==2){ rem(k,p,x); } else
if(op==3){ gg << eok(k,p,x) << "\n"; }
}
return 0;
}