Pagini recente » Cod sursa (job #993526) | Cod sursa (job #35396) | Cod sursa (job #743228) | Cod sursa (job #1958698) | Cod sursa (job #2922287)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("hashuri.in");
ofstream fout ("hashuri.out");
const int mod = 777013;
vector<int>g[mod];
int hashFind (int x){
for (int u : g[x % mod]){
if (u == x){
return true;
}
}
return false;
}
void hashAdd (int x){
g[x % mod].push_back(x);
}
void hashErase (int x){
vector<int>v;
for (int u : g[x % mod]){
if (u != x){
v.push_back(u);
}
}
g[x % mod].clear();
for (int u : v){
g[x % mod].push_back(u);
}
}
int main(){
int q; fin >> q;
while (q--){
int op, x; fin >> op >> x;
if (op == 1){
if (hashFind(x) == false){
hashAdd(x);
}
}
if (op == 2){
if (hashFind(x) == true){
hashErase(x);
}
}
if (op == 3){
fout << hashFind(x) << '\n';
}
}
}