Pagini recente » Cod sursa (job #1252396) | Cod sursa (job #347119) | Cod sursa (job #2730486) | Cod sursa (job #2872016) | Cod sursa (job #1018939)
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#define P 700001
using namespace std;
int n;
vector <list <int> > hesh;
int cauta(int b)
{
int a=b%P;
for(list<int>::iterator k=hesh[a].begin();k!=hesh[a].end();k++)
if(*k==b)
return 1;
return 0;
}
int adauga(int b)
{
int a=b%P;
for(list<int>::iterator k=hesh[a].begin();k!=hesh[a].end();k++)
if(*k==b)
return 1;
hesh[a].push_back(b);
return 0;
}
int sterge(int b)
{
int a=b%P;
for(list<int>::iterator k=hesh[a].begin();k!=hesh[a].end();k++)
if(*k==b)
{hesh[a].erase(k);return 0;}
return 1;
}
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
cin>>n;
int a,b;
hesh.resize(P);
for(int k=1;k<=n;k++)
{
scanf("%d %d",&a,&b);
if(a==1)
adauga(b);
else
if(a==2)
sterge(b);
else
if(a==3)
cout<<cauta(b)<<endl;
}
return 0;
}