Pagini recente » Cod sursa (job #1902505) | Cod sursa (job #2165712) | Cod sursa (job #2365953) | Cod sursa (job #1780042) | Cod sursa (job #1758608)
#include <cstdio>
#include <vector>
using namespace std;
const int MOD = 666013;
vector<int>v[MOD];
vector<int>::iterator find(int x){
int aux = x % MOD;
vector<int>::iterator it;
for (it = v[aux].begin(); it != v[aux].end(); it ++)
if (*it == x)
return it;
return v[aux].end();
}
void insert(int x){
int aux = x % MOD;
if (find(x) == v[aux].end())
v[aux].push_back(x);
}
void erase(int x){
int aux = x % MOD;
vector<int>::iterator it = find(x);
if (it != v[aux].end())
v[aux].erase(it);
}
int main(){
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
int n, i, op, x;
scanf("%d", &n);
for (i = 1; i <= n; i ++){
scanf("%d%d", &op, &x);
if (op == 1)
insert(x);
else if (op == 2)
erase(x);
else
printf("%d\n", find(x) != v[x % MOD].end());
}
return 0;
}