Cod sursa(job #2416542)

Utilizator andreisontea01Andrei Sontea andreisontea01 Data 27 aprilie 2019 18:08:59
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.83 kb
#include <bits/stdc++.h>

using namespace std;

vector<int> hashfct[1000005];

int main()
{
    ifstream fin("hashuri.in");
    ofstream fout("hashuri.out");
    int n, mod = 666013;
    fin >> n;
    for(int i = 1; i <= n; ++i){
        int op, x;
        fin >> op >> x;
        if(op == 1) hashfct[x % mod].push_back(x);
        else if(op == 2){
            for(int i = 0; i < int(hashfct[x % mod].size()); ++i)
                if(hashfct[x % mod][i] == x) hashfct[x % mod].erase(hashfct[x % mod].begin() + i);
        }
        else{
            bool ans = 0;
            for(int i = 0; i < int(hashfct[x % mod].size()); ++i)
                if(hashfct[x % mod][i] == x){
                    ans = 1;
                    break;
                }
            fout << ans << "\n";
        }
    }
    return 0;
}