Pagini recente » Cod sursa (job #239928) | Cod sursa (job #1828143) | Cod sursa (job #3211521) | Cod sursa (job #156212) | Cod sursa (job #731248)
Cod sursa(job #731248)
using namespace std;
#include<cstdio>
#include<vector>
#define MAX 600043
vector <int> G[MAX];
int search(int x, int unsigned i, int unsigned n, int mod)
{
for(;i<n;i++)
if(G[mod][i]==x)
return i;
return -1;
}
void insert(int x)
{
int mod=x%MAX;
if(search(x,0,G[mod].size(),mod)==-1)
G[mod].push_back(x);
}
void remove(int x)
{
int mod=x%MAX;
if(search(x,0,G[mod].size(),mod)!=-1)
G[mod].erase(G[mod].begin()+search(x,0,G[mod].size(),mod));
}
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
int n,op,x;
scanf("%d",&n);
while(n--)
{
scanf("%d %d",&op,&x);
switch(op)
{
case 1: { insert(x); break;}
case 2: { remove(x); break;}
case 3: { if(search(x,0,G[x%MAX].size(),x%MAX)!=-1) printf("1\n"); else printf ("0\n"); break;}
}
}
return 0;
}