Cod sursa(job #1008709)

Utilizator gabrielinelusGabriel-Robert Inelus gabrielinelus Data 11 octombrie 2013 17:59:35
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.99 kb
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
const int Nmax = 1000005;
const int MOD = 666013;
int N;
vector<int> v[ Nmax ];
inline bool apare(int x)
{
    for(vector<int>::iterator it = v[x%MOD].begin();it!= v[x%MOD].end();++it)
        if(*it == x)return true;
    return false;
}
inline void sterge(int x)
{
    for(vector<int>::iterator it= v[x %MOD].begin();it != v[x%MOD].end();++it)
        if( *it == x)
        {
            v[x%MOD].erase(it);
            return;
        }
}
int main()
{
    freopen("hashuri.in","r",stdin);
    freopen("hashuri.out","w",stdout);

    scanf("%d",&N);
    int op,x;
    for(int i = 1; i <= N; ++i)
    {
        scanf("%d%d",&op,&x);
        if( op == 1)
        {
            if(!apare(x))
                v[x%MOD].push_back(x);
        }
        else
            if( op == 2)
                sterge(x);
            else
                printf("%d\n", apare(x));
    }
    return 0;
}