Cod sursa(job #1460116)

Utilizator retrogradLucian Bicsi retrograd Data 11 iulie 2015 16:40:31
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.81 kb
#include <bits/stdc++.h>

using namespace std;

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

#define P 100003
vector<int> B[P];

void insert(int val) {
    vector<int> &V = B[val % P];
    auto it = find(V.begin(), V.end(), val);
    if(it == V.end()) V.push_back(val);
}

void erase(int val) {
    vector<int> &V = B[val % P];
    auto it = find(V.begin(), V.end(), val);
    if(it != V.end()) V.erase(it);
}

bool fnd(int val) {
    vector<int> &V = B[val % P];
    return find(V.begin(), V.end(), val) != V.end();
}


int main() {
    int n, t, a;
    fin>>n;
    while(n--) {
        fin>>t>>a;
        switch(t) {
            case 1: insert(a); break;
            case 2: erase(a); break;
            case 3: fout<<fnd(a)<<'\n'; break;
        }
    }
    return 0;
}