Pagini recente » Cod sursa (job #1822287) | Cod sursa (job #2200892) | Cod sursa (job #157711) | Cod sursa (job #583442) | Cod sursa (job #2890407)
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3F3F3F3F
using namespace std;
const string fisier = "hashuri";
ifstream fin (fisier + ".in");
ofstream fout (fisier + ".out");
const int mod = 666013;
vector<int>g[mod];
auto gasesteHash (int x){
int y = x % mod;
for (auto it = g[y].begin(); it != g[y].end(); ++it){
if (*it == x){
return it;
}
}
return g[y].end();
}
void adaugaHash (int x){
int y = x % mod;
if (gasesteHash(x) == g[y].end()){
g[y].push_back(x);
}
}
void stergeHash (int x){
int y = x % mod;
if (gasesteHash(x) != g[y].end()){
g[y].erase(gasesteHash(x));
}
}
int main(){
ios_base::sync_with_stdio(false);
int q; fin >> q;
while (q--){
int op , x; fin >> op >> x;
if (op == 1){
adaugaHash(x);
continue;
}
else if (op == 2){
stergeHash(x);
continue;
}
fout << (gasesteHash(x) != g[x % mod].end()) << '\n';
}
}