Pagini recente » Cod sursa (job #355290) | Cod sursa (job #540148) | Cod sursa (job #72931) | Cod sursa (job #1512913) | Cod sursa (job #2406126)
#include <fstream>
#include <vector>
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
const int MOD=66013;
vector<int>a[MOD];
vector<int>::iterator findval(int x)
{
int hesh=x%MOD;
vector<int>::iterator it;
for(it=a[hesh].begin();it!=a[hesh].end();it++)
if(*it==x)
return it;
return a[hesh].end();
}
void insertval(int x)
{
int hesh=x%MOD;
if(findval(x)==a[hesh].end())
a[hesh].push_back(x);
}
void eraseval(int x)
{
int hesh=x%MOD;
vector<int>::iterator it=findval(x);
if(it!=a[hesh].end())
a[hesh].erase(it);
}
int main()
{
int x,val;
while(in>>x>>val)
{
if(x==1)
insertval(val);
else if(x==2)
eraseval(val);
else
out<<(findval(val)!=a[val%MOD].end())<<'\n';
}
return 0;
}