Cod sursa(job #1060579)

Utilizator gogol100vrabie gelu gogol100 Data 18 decembrie 2013 09:41:20
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.8 kb
//
//  main.cpp
//  hash
//
//  Created by Gelu Vrabie on 12/18/13.
//  Copyright (c) 2013 Gelu Vrabie. All rights reserved.
//

#include <iostream>
#include <list>
using namespace std;
const int MOD=666013;
typedef list<int> hesh;
hesh ht[MOD];
typedef hesh::iterator hit;
int h(int x)
{
    ht[x%MOD].push_back(x);
}
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,a,x,j;
    cin>>n;
    for(j=1;j<=n;j++)
    {
        cin>>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()) cout<<1<<endl;
        else if(a==3) cout<<0<<endl;
    }
    return 0;
}