Cod sursa(job #2196498)

Utilizator andreiomd1Onut Andrei andreiomd1 Data 19 aprilie 2018 16:10:36
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.79 kb
#include <bits/stdc++.h>
#define MOD 666013

using namespace std;

ifstream f("hashuri.in");
ofstream g("hashuri.out");

int n, i, j, op, x;
vector <int> A[MOD];
bool ok;

int main()
{
    f>>n;

    for(i=1; i<=n; i++) {
        f>>op>>x;

        if(op==1)
            A[x%MOD].push_back(x);

        else if(op==2) {
            for(j=0; j<A[x%MOD].size(); j++)
                if(A[x%MOD][j]==x)
                    A[x%MOD][j]=-1;
        }

        else {
            ok=false;

            for(j=0; j<A[x%MOD].size(); j++)
                if(A[x%MOD][j]==x) {
                    ok=true;
                    break;
                }

            if(ok==true)
                g<<1;
            else g<<0;

            g<<'\n';
        }
    }
    return 0;
}