Pagini recente » Cod sursa (job #2039303) | Cod sursa (job #18233) | Cod sursa (job #945265) | Cod sursa (job #1972720) | Cod sursa (job #1235154)
#include<cstdio>
#include<vector>
#define mod 500000
using namespace std;
vector<int> a[500001];
int i, n, op, x;
bool ok;
void add(int x){
vector<int>::iterator it;
for (it=a[x%mod].begin();it!=a[x%mod].end();it++) {
if (*it==x) return;
}
a[x].push_back(x);
}
void remove(int x){
vector<int>::iterator it;
for (it=a[x%mod].begin();it!=a[x%mod].end();it++) {
if (*it==x) {
a[x%mod].erase(it); return;
}
}
}
bool check(int x){
vector<int>::iterator it;
for (it=a[x%mod].begin();it!=a[x%mod].end();it++) {
if (*it==x) return true;
}
return false;
}
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);
if (op==1) {add(x); continue;}
if (op==2) {remove(x); continue;}
if (op==3) {ok=check(x); if (ok==true) printf("1\n"); else printf("0\n");}
}
return 0;
}