Cod sursa(job #1429623)

Utilizator Miruna_DMiruna Miruna_D Data 6 mai 2015 19:35:11
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.85 kb
#include <iostream>
#include<fstream>
#include <vector>
#define Key 666013
using namespace std;
  ifstream fin("hashuri.in");
  ofstream fout("hashuri.out");

vector <int> G[Key];

int Find(int x)
{
    int List=x%Key;
    for(unsigned int i=0;i<G[List].size();i++)
        if(G[List][i]==x) return i;
    return -1;
}

int Insert(int x)
{
    int List=x%Key;
    int poz=Find(x);
    if(poz==-1)
        G[List].push_back(x);
}

void Delete(int x)
{
    int List=x%Key;
    int poz=Find(x);
    if(poz!=-1)
    G[List].erase(G[List].begin()+poz);
}
int main()
{
   int n;
   fin>>n;
   int i,op,x;
   for(i=1;i<=n;i++)
   {
       fin>>op>>x;
       if(op==1) Insert(x);
       else
        if(op==2) Delete(x);
        else if(Find(x)==-1) fout<<0<<"\n";
                else         fout<<1<<"\n ";
   }
    return 0;
}