Pagini recente » Cod sursa (job #2525574) | Cod sursa (job #3241349) | Cod sursa (job #2528520) | Cod sursa (job #1440037) | Cod sursa (job #982572)
Cod sursa(job #982572)
#include<string.h>
#include<vector>
#include<stdio.h>
#define MOD 666013
using namespace std;
vector <int> has[MOD];
vector <int>::iterator it;
int main () {
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
int op,rest,x,nop,flag;
scanf("%d",&nop);
while( nop ) {
scanf("%d%d",&op,&x);
rest=x%MOD;
if(op==1) {
flag=0;
for(it=has[rest].begin(); it!=has[rest].end() && !flag; it++)
if((*it)==x)
flag=1;
if(!flag)
has[rest].push_back(x);
}
if(op==2) {
for(it=has[rest].begin(); it!=has[rest].end(); it++)
if((*it)==x) {
has[rest].erase(it);
break;
}
}
if(op==3) {
flag=0;
for(it=has[rest].begin(); it!=has[rest].end() && !flag; it++)
if(*it==x)
flag=1;
printf("%d\n",flag);
}
nop--;
}
return 0;
}