Cod sursa(job #2541817)

Utilizator maco1503Macovei Teodor-Andrei maco1503 Data 8 februarie 2020 22:30:39
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.84 kb
#include <bits/stdc++.h>
using namespace std;

#define p 700027

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


vector < int > h[p];

vector<int>::iterator tip3 (int x)
{
    int k=x%p;
    for (vector<int>::iterator it = h[k].begin() ; it != h[k].end(); ++it)
        if(*it == x)return it;

    return h[k].end();

}
void tip1(int x)
{
    int k=x%p;
    if(tip3(x)==h[k].end())h[k].push_back(x);
}
void tip2(int x)
{
    int k=x%p;
    vector<int>::iterator it = tip3(x);
    if(tip3(x)!=h[k].end())h[k].erase(it);
}

int main()
{
    long long n;
    in>>n;
    for(int x,y,i=1;i<=n;i++)
    {
        in>>x;
        if(x==1){in>>y;tip1(y);}
        if(x==2){in>>y;tip2(y);}
        if(x==3){in>>y;out<<(tip3(y)!=h[y%p].end())<<'\n';}
    }


    in.close();
    out.close();
    return 0;
}