Cod sursa(job #828825)

Utilizator andreidanAndrei Dan andreidan Data 4 decembrie 2012 15:17:19
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.86 kb
#include <cstdio>
#include <vector>

#define mod 666013

using namespace std;

vector <int> v[mod+5];

int find(int x){
    int poz = x % mod, i, lim;
    lim = v[poz].size();

    for(i=0;i<lim;++i){
        if(v[poz][i] == x) return i;
    }
    return -1;
}


int main (){
    int n,i,m,x,poz;

    freopen("hashuri.in","r",stdin);
    freopen("hashuri.out","w",stdout);

    scanf("%d", &n);

    for(i = 1 ; i <= n ; ++i){
        scanf("%d %d", &m, &x);

        poz = x % mod;

        if(m == 1){
            if(find(x) == -1)
                v[poz].push_back(x);
        }

        if(m == 2){
            if(find(x) > -1)
                v[poz].erase(v[poz].begin() + find(x));
        }
        if(m == 3){
            if(find(x) > -1) printf("1\n");
                else printf("0\n");
        }



    }



}