Pagini recente » Cod sursa (job #155999) | Cod sursa (job #324986) | Cod sursa (job #2507118) | Cod sursa (job #2858471) | Cod sursa (job #1060584)
//
// main.cpp
// hash
//
// Created by Gelu Vrabie on 12/18/13.
// Copyright (c) 2013 Gelu Vrabie. All rights reserved.
//
#include <fstream>
#include <list>
using namespace std;
const int MOD=666013;
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()
{
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int n,a,x,j;
f>>n;
for(j=1;j<=n;j++)
{
f>>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()) g<<1<<endl;
else if(a==3) g<<0<<endl;
}
return 0;
}