Cod sursa(job #631659)

Utilizator Lokycatalin petre Loky Data 9 noiembrie 2011 13:53:37
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.9 kb
#include <fstream>
#include <vector>
#define mod 666013

using namespace std;

vector <int> h[mod];
vector <int>:: iterator it;
int i,x,y,n,ind;
bool ok;

int main()
{
    ifstream f("hashuri.in");
    ofstream g("hashuri.out");
    f>>n;
    for (i=1;i<=n;i++) {
    f>>x>>y;
    ind=y%mod;
    if (x==1) {
        ok=true;
        for (it=h[ind].begin();it!=h[ind].end();it++)
        if (*it==y) {ok=false;break;}
        if (ok==true) h[ind].push_back(y);
    }
    if (x==2) {
        ok=true;
         for (it=h[ind].begin();it!=h[ind].end();it++)
         if (*it==y) {ok=false;break;}
         if (ok==false) h[ind].erase(it);
    }
    if (x==3) {
         ok=true;
         for (it=h[ind].begin();it!=h[ind].end();it++)
         if (*it==y) {g<<'1'<<'\n';ok=false;break;}
         if (ok==true) g<<'0'<<'\n';
    }
    }
    f.close();
    g.close();
    return 0;
}