Cod sursa(job #976480)

Utilizator victor_crivatCrivat Victor victor_crivat Data 23 iulie 2013 12:34:53
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.92 kb

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <fstream>
#include <vector>
#define Mod 666013
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
vector <int> H[Mod];
vector <int> :: iterator it;
int n,i,op,x,ind;
bool ok;
int main ()
{
   f>>n;
    for (i=1;i<=n;i++)
    {
       f>>op>>x;
        ind=x%Mod;
        ok=false;
        for (it=H[ind].begin();it!=H[ind].end();it++)
        {
            if (*it==x) break;
        }
        if (op==1)
        {
           if (it == H[ind].end()) H[ind].push_back(x);
        }
        else if (op==2)
        {
           if (it!=H[ind].end()) H[ind].erase(it);
        }
        else if (op==3)
        {
            if(it==H[ind].end()) g<<'0'<<'\n';
            else g<<'1'<<'\n';
        }
    }

    return 0;
}