Pagini recente » Cod sursa (job #1591499) | Cod sursa (job #1393578) | Cod sursa (job #533143) | Cod sursa (job #714722) | Cod sursa (job #1966983)
#include<bits/stdc++.h>
using namespace std;
#define MOD 666013
int N;
vector<int> G[MOD];
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
vector<int>::iterator find_value(int x){
int list = x % MOD;
vector<int>::iterator it;
for (it = G[list].begin(); it != G[list].end(); ++it)
if (*it == x)
return it;
return G[list].end();
}
void insert_value(int x){
int list = x % MOD;
if (find_value(x) == G[list].end())
G[list].push_back(x);
}
void erase_value(int x){
int list = x % MOD;
vector<int>::iterator it = find_value(x);
if (it != G[list].end())
G[list].erase(it);
}
int main(){
int op, x;
fin>>N;
while(N--){
fin>>op>>x;
if (op == 1){
insert_value(x);
continue;
}
if (op == 2){
erase_value(x);
continue;
}
fout<< bool(find_value(x) != G[x % MOD].end())<<'\n';
}
return 0;
}