Cod sursa(job #979500)

Utilizator alex_HarryBabalau Alexandru alex_Harry Data 1 august 2013 19:39:06
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.01 kb
#include <fstream>
#include <vector>
#define MOD 666013
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
vector <int> V[MOD];
int N;
vector <int> :: iterator Find(int value)
{
    int List=value%MOD;
    vector <int>:: iterator it;
    for(it=V[List].begin();it!=V[List].end();it++)
    {
        if(*it==value)
            return it;
    }
    return V[List].end();
}
void Insert(int value)
{
      int List=value%MOD;
      if(Find(value)==V[List].end())
            V[List].push_back(value);
}
void Delete(int value)
{
    int List=value%MOD;
     vector <int>:: iterator it=Find(value);
    if(it!=V[List].end())
        V[List].erase(it);
}
void Solve()
{
    int op,value;
    while(N!=0)
    {
        f>>op>>value;
        if(op==1)
            Insert(value);
        if(op==2)
            Delete(value);
        if(op==3)
            g<<(Find(value)!=V[value%MOD].end())<<"\n";
        N--;
    }
}
int main()
{
    f>>N;
    Solve();
    return 0;
}