Cod sursa(job #2194176)

Utilizator bigmixerVictor Purice bigmixer Data 12 aprilie 2018 15:34:40
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 1.3 kb
#include <bits/stdc++.h>
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define pb push_back
#define er erase
#define in insert
#define fr first
#define sc second
#define mp make_pair
#define pi pair
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
#define rc(s) return cout<<s,0
const int huh=666013;
using namespace std;
std::vector<int>::iterator it;
vector<int>lel[huh];
int n;
int x;
char t;
bool lol;

bool findo(int y){
    int iopta=y%huh;
     for(int i=0;i<lel[iopta].size();i++){
        if(lel[iopta][i]==y) return true;
     }

     return false;
}


int main(){ _
    ifstream fin("hashuri.in");
    ofstream fout("hashuri.out");
    fin >> n;
    for(int i=1;i<=n;i++){
        fin >> t >> x;
        int you=x%huh;
        if(t=='1'){
            if(findo(x)==false)lel[you].push_back(x);
            continue;
        }
        if(t=='2'){
            it=lel[you].begin();
            while(it!=lel[you].end()){
                if(*it==x){ lel[you].erase(it); break; }
                it++;
            }
        }
            if(findo(x)==true) fout<<1<<endl;
            else fout<<0<<endl;



    }
}