Pagini recente » Cod sursa (job #997765) | Cod sursa (job #1396529) | Cod sursa (job #1239911) | Cod sursa (job #1090422) | Cod sursa (job #640489)
Cod sursa(job #640489)
#include <cstdio>
#include <vector>
#define MOD 666013
using namespace std;
int n;
vector<int> t_hash[MOD+5];
typedef vector<int>::iterator it;
//ifstream f("hashuri.in");
//ofstream g("hashuri.out");
void citeste(){
//f>>n;
scanf("%d\n", &n);
}
it afla_iterator(int x){
int h_x = x % MOD;
for(it i=t_hash[h_x].begin(); i != t_hash[h_x].end(); ++i){
if (*i == x)
return i;
}
return t_hash[h_x].end();
}
void sterge(int x){
it ite = afla_iterator(x);
int h_x = x % MOD;
if (ite != t_hash[h_x].end())
t_hash[h_x].erase(ite);
}
void adauga(int x){
it ite = afla_iterator(x);
int h_x = x % MOD;
if (ite == t_hash[h_x].end())
t_hash[h_x].push_back(x);
}
void rezolva(){
for(int i=1; i<=n; ++i){
int x,y;
//f>>x>>y;
scanf("%d %d\n", &x, &y);
if (x == 1){
adauga( y );
}else if (x == 2){
sterge( y );
}else if (x == 3){
int h_x = y % MOD;
if (afla_iterator(y) == t_hash[h_x].end())
//g<<"0"<<"\n";
printf("%d\n", 0);
else //g<<"1"<<"\n";
printf("%d\n", 1);
}
}
}
int main(){
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
citeste();
rezolva();
//f.close();
//g.close();
return 0;
}