Pagini recente » Cod sursa (job #2732988) | Cod sursa (job #1993935) | Cod sursa (job #279573) | Cod sursa (job #1431404) | Cod sursa (job #642437)
Cod sursa(job #642437)
#include <stdio.h>
#include <list>
using namespace std;
#define MOD 666013
int n;
list<unsigned int> hash[MOD];
inline list<unsigned int>::iterator gaseste(unsigned int x){
unsigned int ind=x%MOD;
list<unsigned int>::iterator it;
for (it=hash[ind].begin(); it!=hash[ind].end(); it++)
if (*it==x) return it;
return hash[ind].end();
}
void insert(unsigned int x){
unsigned int ind=x%MOD;
if (gaseste(x)==hash[ind].end())
hash[ind].push_back(x);
}
/*void sterge(int x){
unsigned int ind=x%MOD;
list<unsigned int>::iterator itt=gaseste(x);
if (itt!=hash[ind].end())
hash[ind].erase(itt);
}
*/
int main(){
unsigned int op,nr;
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&n);
for (int i=1;i<=n;i++){
scanf("%d %d",&op,&nr);
if (op==1) insert(nr);
if (op==2) hash[nr%MOD].remove(nr);
if (op==3) printf("%d\n",gaseste(nr)==hash[nr%MOD].end()?0:1);
}
return 0;
}