Pagini recente » Cod sursa (job #174888) | Cod sursa (job #2513853) | Cod sursa (job #1787006) | Cod sursa (job #436759) | Cod sursa (job #340288)
Cod sursa(job #340288)
#include <iostream>
#include <fstream>
#include <vector>
#define MAX 666013
using namespace std;
vector<long> v[MAX];
long n,op,x;
long is(long x){
long mod=x%MAX;
for (vector<long>::iterator i=v[mod].begin(); i!=v[mod].end(); i++){
if(x==*i)
return 1;
}
return 0;
}
void insertx(long x){
if(0==is(x))
v[x%MAX].push_back(x);
}
void erasex(long x){
if(1==is(x)){
long mod=x%MAX;
for (vector<long>::iterator i=v[mod].begin(); i!=v[mod].end(); i++){
if (x==*i){
v[mod].erase(i);
return;
}
}
}
}
int main(){
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
for(fin >> n; n; --n){
fin >> op >> x;
if(op==1){
insertx(x);
}
if(op==2){
erasex(x);
}
if(op==3){
fout << is(x) << "\n";
}
}
return 0;
}