Pagini recente » Cod sursa (job #2799116) | Cod sursa (job #444660) | Cod sursa (job #2183222) | Cod sursa (job #2296228) | Cod sursa (job #773667)
Cod sursa(job #773667)
#include<cstdio>
#include<vector>
#define Mod 666013
using namespace std;
vector <int> h[Mod];
vector <int> :: iterator it;
int i, x, op, ind, n;
inline vector <int> :: iterator find_v(int x){
for (it=h[ind].begin();it!=h[ind].end();it++)
if (*it==x) return it;
return it;
}
inline void insert_v(int x) {
if (it==h[ind].end()) h[ind].push_back(x);
}
inline void erase_v(int x) {
if (it!=h[ind].end()) h[ind].erase(it);
}
inline void print_v(int x) {
if (it==h[ind].end()) printf("0\n"); else printf("1\n");
}
int main(){
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d", &n);
for (i=1;i<=n;i++) {
scanf("%d%d", &op, &x);
ind=x/Mod;
it=find_v(x);
if (op==1) insert_v(x);
if (op==2) erase_v(x);
if (op==3) print_v(x);
}
return 0;
}