Pagini recente » Cod sursa (job #1078870) | Cod sursa (job #2813172) | Cod sursa (job #60577) | Cod sursa (job #867082) | Cod sursa (job #1451349)
#include<cstdio>
#include<string>
#include<vector>
using namespace std;
#ifdef HOME
const string inputFile = "input.txt";
const string outputFile = "output.txt";
#else
const string problemName = "hashuri";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";
#endif
const int MOD = 666013;
int N;
vector<int> V[MOD + 5];
void add(int x) {
int r = x % MOD;
for (auto y : V[r])
if (y == x)
return;
V[r].push_back(x);
}
void erase(int x) {
int r = x % MOD;
for (auto &y : V[r])
if (y == x) {
swap(y, V[r].back());
V[r].pop_back();
return;
}
}
int find(int x) {
int r = x % MOD;
for (auto y : V[r])
if (y == x)
return 1;
return 0;
}
int main() {
int t, x;
freopen(inputFile.c_str(), "r", stdin);
freopen(outputFile.c_str(), "w", stdout);
scanf("%d", &N);
while (N--) {
scanf("%d%d", &t, &x);
if (t == 1) {
add(x);
continue;
}
if (t == 2) {
erase(x);
continue;
}
if (t == 3) {
printf("%d\n", find(x));
continue;
}
}
return 0;
}