Pagini recente » Cod sursa (job #1026549) | Cod sursa (job #1976776) | Cod sursa (job #601924) | Rating borza maria (cristina2000) | Cod sursa (job #731889)
Cod sursa(job #731889)
#include <fstream>
#include <set>
using namespace std;
# define prim 19937
set <int> h[prim];
int main(){
int n,op,x,i;
ifstream f ("hashuri.in");
ofstream g ("hashuri.out");
f>>n;
for (i=0;i<n;i++){
f>>op>>x;
if (op==1)
if(h[x%prim].find(x)==h[x%prim].end())//if x doesn't already exists
h[x%prim].insert(x);
if (op==2)
if(h[x%prim].find(x)!=h[x%prim].end())//if x exists
h[x%prim].erase(x);
if (op==3)
if(h[x%prim].find(x)==h[x%prim].end())
g<<"0"<<endl;
else
g<<"1"<<endl;
}
return 0;
}