Pagini recente » Cod sursa (job #477301) | Cod sursa (job #2493713) | Cod sursa (job #1611041) | Cod sursa (job #1085608) | Cod sursa (job #1060583)
#include <fstream>
#include <list>
using namespace std;
const int MOD=666013;
typedef list<int> hesh;
typedef hesh::iterator hit;
hesh ht[MOD+10];
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;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
in>>n;
int op,param;
for(int i=1;i<=n;i++)
{
in>>op>>param;
hit cnt=find(param);
if(op==1)
{
if(cnt==ht[param%MOD].end())
ht[param%MOD].push_back(param);
}
else if(op==2)
{
if(cnt!=ht[param%MOD].end())
ht[param%MOD].erase(cnt);
}
else if(op==3)
{
if(cnt!=ht[param%MOD].end())
out<<1<<endl;
else out<<0<<endl;
}
}
return 0;
}