Cod sursa(job #1852729)

Utilizator marumatMatei Marussi Alexandru marumat Data 21 ianuarie 2017 10:00:35
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.82 kb
#include <fstream>
#include <vector>
#define MOD 666013
#define pb push_back
using namespace std;
vector <int>:: iterator it;
vector <int> h[MOD];
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int n,i,j,x,y,ok;
int main()
{
    f>>n;
    for(i=1;i<=n;i++)
    {f>>x>>y; ok=0;
    if(x==1){
        for(j=0;j<h[y%MOD].size();j++)
        if(h[y%MOD][j]==y)ok=1;
        if(ok==0)
            h[y%MOD].push_back(y);
    }
        else if(x==2)
        {
            for(it=h[y%MOD].begin();it!=h[y%MOD].end();it++)
                   if(*it==y)
                    {h[y%MOD].erase(it); break;}

        }
            else if(x==3)
            { for(it=h[y%MOD].begin();it!=h[y%MOD].end();it++)
                 if(*it==y)ok=1;
                 g<<ok<<'\n';
            }

    }
    return 0;
}