Pagini recente » Cod sursa (job #2932590) | Cod sursa (job #2031414) | Cod sursa (job #1033555) | Cod sursa (job #2130115) | Cod sursa (job #3151745)
#include <bits/stdc++.h>
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
const int mod = 666013;
vector<int> h[mod];
int n;
int op, x;
void add(int x) {
int y = x % mod;
for (auto it : h[y])
if (x == it)
return;
h[y].push_back(x);
}
void del(int x) {
int y = x % mod;
for (int i = 0; i < h[y].size(); i++)
if (h[y][i] == x) {
swap(h[y][i], h[y][h[y].size() - 1]);
h[y].pop_back();
break;
}
}
bool is(int x) {
int y = x % mod;
for (auto it : h[y])
if (it == x)
return 1;
return 0;
}
int main()
{
in >> n;
for (int i = 1; i <= n; i++) {
in >> op >> x;
if (op == 1) {
add(x);
} else if (op == 2) {
del(x);
} else {
out << is(x) << '\n';
}
}
return 0;
}