Pagini recente » Cod sursa (job #1564819) | Cod sursa (job #1995833) | Cod sursa (job #1656761) | Cod sursa (job #3137813) | Cod sursa (job #2108225)
#include <iostream>
#include<bits/stdc++.h>
#define PRIM 666013
using namespace std;
vector<int> hashTable[PRIM];
int cauta(int x)
{
for(unsigned i=0;i!=hashTable[x%PRIM].size();++i)
if(x==hashTable[x%PRIM][i]) return i;
return -1;
}
int main()
{
int n,i,op,x,poz;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
f>>n;
for(i=0;i<n;++i)
{
f>>op>>x;
if(op==1) {if(cauta(x)==-1) hashTable[x%PRIM].push_back(x);}
else if(op==2) {int poz=cauta(x);if(poz>=0) hashTable[x%PRIM].erase(hashTable[x%PRIM].begin()+poz);}
else g<<!(!(cauta(x)+1))<<'\n';
}
return 0;
}