Pagini recente » Cod sursa (job #72825) | Cod sursa (job #1813883) | Cod sursa (job #3266835) | Cod sursa (job #1387283) | Cod sursa (job #1060586)
#include <fstream>
#include <list>
using namespace std;
const int MOD=36013;
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;
}