Pagini recente » Cod sursa (job #676906) | Cod sursa (job #1406500) | Cod sursa (job #994428) | Cod sursa (job #2497147) | Cod sursa (job #1218372)
#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 h(int x) {
return x % P;
}
int find_(int x)
{
int i;
for (i=0;i<H[h(x)].size() && H[h(x)][i]!=x;i++);
return (i<H[h(x)].size());
}
void Add(int x)
{
if (!find_(x)) H[h(x)].push_back(x);
}
void pop(int x)
{
for (int i=0;i<H[h(x)].size();i++)
if (H[h(x)][i]==x) {
H[h(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;
}