Pagini recente » Cod sursa (job #1944706) | Cod sursa (job #1571399) | Cod sursa (job #2374279) | Cod sursa (job #2584460) | Cod sursa (job #2591241)
#include <bits/stdc++.h>
using namespace std;
const int mod = 666013;
int n, key, x;
vector<int> h[mod];
vector<int>::iterator find_value(int x) {
int f = x % mod;
for (vector<int>::iterator it = h[f].begin(); it != h[f].end(); it++)
if (*it == x)
return it;
return h[x].end();
}
void insert_value(int x) {
int f = x % mod;
if (find_value(x) == h[f].end())
h[f].push_back(x);
}
void erase_value(int x) {
int f = x % mod;
if (find_value(x) != h[f].end())
h[f].push_back(x);
}
bool contains_value(int x) {
int f = x % mod;
if (find_value(x) != h[f].end())
return true;
return false;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
cin >> n;
while (n--) {
cin >> key >> x;
if (key == 1)
insert_value(x);
else if (key == 2)
erase_value(x);
else
cout << contains_value(x) << "\n";
}
}