Pagini recente » Cod sursa (job #2086726) | Cod sursa (job #2491590) | Cod sursa (job #753084) | Cod sursa (job #3176792) | Cod sursa (job #1060580)
//
// main.cpp
// hash
//
// Created by Gelu Vrabie on 12/18/13.
// Copyright (c) 2013 Gelu Vrabie. All rights reserved.
//
#include <iostream>
#include <list>
using namespace std;
const int MOD=66013;
typedef list<int> hesh;
hesh ht[MOD];
typedef hesh::iterator hit;
hit find(int x){
for(hit i=ht[x%MOD].begin();i!=ht[x%MOD].end();i++)
if(x==*i)
return i;
return ht[x%MOD].end();
}
int main()
{
int n,a,x,j;
cin>>n;
for(j=1;j<=n;j++)
{
cin>>a>>x;
if(a==1 && find(x)==ht[x%MOD].end()) ht[x%MOD].push_back(x);
else if(a==2 && find(x)!=ht[x%MOD].end()) ht[x%MOD].erase(find(x));
else if(a==3 && find(x)!=ht[x%MOD].end()) cout<<1<<endl;
else if(a==3) cout<<0<<endl;
}
return 0;
}