Pagini recente » Cod sursa (job #5030) | Cod sursa (job #2054273) | Cod sursa (job #2340796) | Cod sursa (job #1786550) | Cod sursa (job #1218371)
#include<fstream>
#include<vector>
using namespace std;
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
const int P = 666013;
vector<int> H[P];
int n;
int hash(int x) {
return x % P;
}
int find(int x)
{
int i;
for (i=0;i<H[hash(x)].size() && H[hash(x)][i]!=x;i++);
return (i<H[hash(x)].size());
}
void Add(int x)
{
if (!find(x)) H[hash(x)].push_back(x);
}
void pop(int x)
{
for (int i=0;i<H[hash(x)].size();i++)
if (H[hash(x)][i]==x) {
H[hash(x)][i]=-1;
break;
}
}
int main()
{
cin>>n;
for (;n--;)
{
int op,x;
cin>>op>>x;
if (op == 1)
Add(x);
if (op==2)
pop(x);
if (op==3)
cout<<find(x)<<"\n";
}
return 0;
}