Cod sursa(job #1121750)

Utilizator visanrVisan Radu visanr Data 25 februarie 2014 13:56:10
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.91 kb
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

const int MOD = 60001;

int N, Type, X;
vector<int> Hash[MOD];

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

    scanf("%i", &N);
    for(; N; N --)
    {
        scanf("%i %i", &Type, &X);
        if(Type == 1)
        {
            int Key = X % MOD;
            if(find(Hash[Key].begin(), Hash[Key].end(), X) == Hash[Key].end())
                Hash[Key].push_back(X);
        }else if(Type == 2)
        {
            int Key = X % MOD;
            if(find(Hash[Key].begin(), Hash[Key].end(), X) != Hash[Key].end())
                Hash[Key].erase(find(Hash[Key].begin(), Hash[Key].end(), X));
        }else
        {
            int Key = X % MOD;
            printf("%i\n", find(Hash[Key].begin(), Hash[Key].end(), X) != Hash[Key].end());
        }
    }
}