Cod sursa(job #1813957)

Utilizator AlexandruRudiAlexandru Rudi AlexandruRudi Data 23 noiembrie 2016 15:37:27
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.75 kb
#include <bits/stdc++.h>

using namespace std;

int MOD=666013;
int n,x,y;
bool found;
vector <int> h[666017];

int main(){
    ifstream in("hashuri.in");
    ofstream out("hashuri.out");
    in >> n;
    for(int i=1;i<=n;i++){
        in >> x >> y;
        if(x==1){
            h[y%MOD].push_back(y);
        }
        if(x==2){
            for(auto it=h[y%MOD].begin();it!=h[y%MOD].end();it++){
                if(*it==y) h[y%MOD].erase(it);
                if(it==h[y%MOD].end()) break;
            }
        }
        if(x==3){
            found=false;
            for(auto it=h[y%MOD].begin();it!=h[y%MOD].end();it++){
                if(*it==y) found=true;
            }
            out << found << '\n';
        }
    }
}