Cod sursa(job #2541814)

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

#define p 700027

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


vector < int > h;

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

    return h.end();

}
void tip1(int x)
{
    int k=x%p;
    if(tip3(x)==h.end())h.push_back(x);
}
void tip2(int x)
{
    int k=x%p;
    vector<int>::iterator it = tip3(x);
    if(tip3(x)!=h.end())h.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.end())<<'\n';}
    }


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