Cod sursa(job #1193464)

Utilizator ZenusTudor Costin Razvan Zenus Data 31 mai 2014 20:26:45
Problema Hashuri Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.79 kb
#include <cstdio>
#include <vector>

using namespace std;

#define MOD 666013
#define LL long long

vector < LL > H[MOD];
LL type,N,X;
vector < LL > :: iterator it;

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

scanf("%lld",&N);

while (N--)
{
    scanf("%lld",&type);
    scanf("%lld",&X);
    for (it=H[X%MOD].begin();it!=H[X%MOD].end();++it)
    if (*it==X) break;

    if (type==1)
    {
        if (!H[X%MOD].empty() && *it==X) continue;
        H[X%MOD].push_back(X);
        continue;
    }

    if (type==2)
    {
        if (H[X%MOD].empty() || it==H[X%MOD].end()) continue;

        H[X%MOD].erase(it);
        continue;
    }

    if (!H[X%MOD].empty() && *it==X) printf("1\n");
    else printf("0\n");
}

return 0;
}