Cod sursa(job #1215514)

Utilizator bogdan10bosBogdan Sitaru bogdan10bos Data 1 august 2014 10:57:39
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.75 kb
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>

#define mod 666013

using namespace std;
int t, op, x, y, ok;
vector <int> v[666013];
vector <int>::iterator it;
int main()
{
    freopen("hashuri.in", "r", stdin);
    freopen("hashuri.out", "w", stdout);
    scanf("%d", &t);
    while(t)
    {
        t--;
        scanf("%d%d", &op, &x);
        y=x%mod;

        for(it=v[y].begin();it!=v[y].end();it++)
            if(*it==x) break;

        if(it!=v[y].end()) ok=1;
        else ok=0;

        if(op==1&&ok==0) v[y].push_back(x);
        if(op==2&&ok==1) v[y].erase(it);
        if(op==3) printf("%d\n", ok);
    }
    return 0;
}