Cod sursa(job #3243366)

Utilizator Bolfa_DBolfa Diana Bolfa_D Data 17 septembrie 2024 20:23:39
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.03 kb
#include <bits/stdc++.h>
#define MOD 666013
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");

vector<int> h[MOD+10];
int ok, n,x, c, y;
int main()
{
    fin>>n;
    for(int i=1;i<=n;++i)
    {
        fin>>c>>x;
        y=x%MOD;
        if(c==1)
        {
            if(h[y].empty()==true)
                h[y].push_back(x);
            else{
                ok=1;
                for(auto j:h[y])
                    if(j==x)
                        ok=0;
                if(ok==1)
                    h[y].push_back(x);
            }
        }
        if(c==2)
        {
            vector<int>:: iterator j;
            for(j=h[y].begin();j!=h[y].end();++j)
                if(*j==x)
                {
                    h[y].erase(j);
                    --j;
                }
        }
        if(c==3)
        {
            ok=0;
            for(auto j:h[y])
                if(j==x)
                    ok=1;
            fout<<ok<<'\n';
        }
    }
    return 0;
}