Pagini recente » Cod sursa (job #2217786) | Cod sursa (job #262713) | Cod sursa (job #1493851) | Cod sursa (job #185119) | Cod sursa (job #2100011)
#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 (op==1) {add(x); continue;}
if (op==2) {remove(x); continue;}
if (op==3) {ok=check(x); if (ok) printf("1\n"); else printf("0\n");}
}
return 0;
}