Pagini recente » Cod sursa (job #735146) | Cod sursa (job #1335403) | Cod sursa (job #1938069) | Cod sursa (job #3176614) | Cod sursa (job #971834)
Cod sursa(job #971834)
#include <cstdio>
#include <vector>
using namespace std;
vector <int> H[666013];
vector <int> :: iterator it;
int i, n, op, x, ind;
vector <int> :: iterator find_v(int x)
{
for(it= H[ind].begin(); it!=H[ind].end(); it++)
if (*it==x) return it;
return it;
}
int main()
{
freopen ("hashuri.in","r", stdin);
freopen("hashuri.out","w", stdout);
scanf("%d\n", &n);
for (int i=1; i<=n; i++)
{
scanf("%d %d\n", &op, &x);
ind = x % 666013;
it = find_v(x);
if(op==1) if (it == H[ind].end()) H[ind].push_back(x);
if(op==2) if (it!=H[ind].end()) H[ind].erase(it);
if(op==3) if(it==H[ind].end()) printf("0\n");
else printf("1\n");
}
return 0;
}