Cod sursa(job #773668)

Utilizator costyrazvyTudor Costin Razvan costyrazvy Data 2 august 2012 12:39:53
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.74 kb
#include <fstream>
#include <vector>
#define mod 666013
#define pb push_back

using namespace std;

vector <int> h[mod];
vector <int> :: iterator it;
int i, ind, n, op, x;
ifstream f("hashuri.in");
ofstream g("hashuri.out");


inline vector <int> :: iterator find_v(int x)
{
   for (it = h[ind].begin() ; it != h[ind].end() ; it++)
    if (*it==x) return it;
    return it;
}
int main()
{
    f>> n;
    for ( i=1;i<=n;i++)
    {
        f>> op>> x;
        ind=x%mod;
        it=find_v(x);
        if (op==1)  if (it==h[ind].end()) h[ind].pb(x);
        if (op==2)  if (it!=h[ind].end()) h[ind].erase(it);
        if (op==3)  if(it==h[ind].end()) g<<"0"<<'\n'; else g<<"1"<<'\n';
    }
    f.close();
    g.close();
}