Pagini recente » Cod sursa (job #24995) | Cod sursa (job #2429417) | Cod sursa (job #1074077) | Cod sursa (job #1405238) | Cod sursa (job #1235163)
#include<cstdio>
#include<vector>
#define MOD 500000
using namespace std;
vector<int> a[500002];
int i, n, op, x;
bool ok;
void add(int x){
vector<int>::iterator it;
if (a[x%MOD].empty()) {
a[x%MOD].push_back(x); return;
}
for (it=a[x%MOD].begin();it!=a[x%MOD].end();it++) {
if (*it==x) return;
}
a[x%MOD].push_back(x);
}
void remove(int x){
vector<int>::iterator it;
if (a[x%MOD].empty()) return;
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;
if (a[x%MOD].empty()) return false;
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 (i==8029) {
op=op;
}
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;
}