Pagini recente » Cod sursa (job #1241019) | Cod sursa (job #2847041) | Cod sursa (job #1983361) | Cod sursa (job #2892169) | Cod sursa (job #1233277)
#include <fstream>
#include <vector>
using namespace std;
const char Infile[]="hashuri.in";
const char OutFile[]="hashuri.out";
const int mod=666013;
ifstream in(Infile);
ofstream out(OutFile);
vector<int> hashtable[mod];
vector<int>::iterator it;
int n,i;
inline vector<int>::iterator Find(int x)
{
int t=i%mod;
for(it=hashtable[t].begin();it!=hashtable[t].end();++it)
if(*it==x) return it;
return hashtable[t].end();
}
inline void ins(int x)
{
int t=i%mod;
for(it=hashtable[t].begin();it!=hashtable[t].end();++it)
if(*it==x) return;
hashtable[t].push_back(x);
}
inline void ers(int x)
{
int t=i%mod;
for(it=hashtable[t].begin();it!=hashtable[t].end();++it)
{
if(*it==x)
{
hashtable[t].erase(it);
return;
}
}
}
int main()
{
int op;
in>>n;
while(in>>op>>i)
{
if(op==1)
{
ins(i);
continue;
}
if(op==2)
{
ers(i);
continue;
}
if(op==3 && Find(i)!=hashtable[i%mod].end())
out<<"1"<<endl;
else if(op==3) out<<"0"<<endl;
}
return 0;
}