Cod sursa(job #2659560)

Utilizator nicuvladNicu Vlad nicuvlad Data 17 octombrie 2020 07:39:17
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.75 kb
#include <bits/stdc++.h>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int x,y,t,h;
const int M=700095;
vector <int>v[M];
void adauga()
{
    for(auto it:v[h])
        if(it==x)return;
    v[h].push_back(x);
}
void sterge()
{
    for(vector<int>::iterator it=v[h].begin();it!=v[h].end();it++)
        if(*it==x){
           v[h].erase(it);
           return;
        }
}
bool querry()
{
    for(auto it:v[h])
        if(it==x)return 1;
    return 0;
}
int main()
{
    ios_base::sync_with_stdio(0);
    fin.tie(0);
    fin>>t;
    while(t--)
    {
        fin>>y>>x;
        h=x%M;
        if(y==1)adauga();
        else if(y==2)sterge();
        else fout<<querry()<<'\n';
    }
    return 0;
}