Cod sursa(job #2410176)

Utilizator flaviu_2001Craciun Ioan-Flaviu flaviu_2001 Data 19 aprilie 2019 19:52:06
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.95 kb
#include <bits/stdc++.h>
#define ff first
#define ss second

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;

const string file = "hashuri";
const ll INF = 9223372036854775807ll;
const int inf = 2147483647, M = 666013;

int test;
vector<int> v[M+5];

vector<int>::iterator where(int x)
{
    for (vector<int>::iterator it = v[x%M].begin(); it != v[x%M].end(); ++it)
        if(*it == x)
            return it;
    return v[x%M].end();
}

int main()
{
    ifstream fin (file+".in");
    ofstream fout (file+".out");
    fin >> test;
    while(test--){
        int t, x;
        fin >> t >> x;
        if(t == 1){
            if(where(x) == v[x%M].end())
                v[x%M].push_back(x);
        }else if (t == 2){
            vector<int>::iterator it = where(x);
            if(it != v[x%M].end())
                v[x%M].erase(it);
        }else
            fout << (where(x) != v[x%M].end()) << "\n";
    }
    return 0;
}