Cod sursa(job #2617317)

Utilizator VladAlexandruAnghelache Vlad VladAlexandru Data 21 mai 2020 14:10:00
Problema Hashuri Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.87 kb
#include <bits/stdc++.h>

using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
const int m=666013;
void op_1(int x);
void op_2(int x);
bool op_3(int x);
struct hsh
{
    vector<vector<int>>h;
}H;

void op_1(int x)
{
    if(op_3(x)==0)
    {
        int y=x%m;
        H.h[y].push_back(x);
    }
}

void op_2(int x)
{
    int y=x%m;
    int i=0;

    for(auto&it:H.h[y])
    {

        if(it==x)
            H.h[y].erase(H.h[y].begin()+i);
        i++;
    }
}

bool op_3(int x)
{
    int y=x%m;
    for(auto&it:H.h[y])
        if(it==x)
            return 1;
    return 0;
}



int main()
{
    int n;
    while(n--)
    {
        int op,x;
        fin>>op>>x;
        if(op==1)
            op_1(x);
        else if(op==2)
            op_2(x);
        else fout<<op_3(x)<<"\n";

    }
    return 0;
}