Pagini recente » Cod sursa (job #1374985) | Cod sursa (job #883530) | Cod sursa (job #837746) | Cod sursa (job #623747) | Cod sursa (job #1054741)
#include<fstream>
#include<list>
#define HASH 941712
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
list<int>L[HASH];
list<int>::iterator it;
int T, x, y, i, op, exista;
int main(){
fin>>T;
for(;T;T--){
fin>>op>>x;
y=x%HASH;
if(op==1){
exista=0;
for(it=L[y].begin();it!=L[y].end();it++){
if(*it==x){
exista=1;
}
}
if(!exista){
L[y].push_back(x);
}
}
if(op==2){
for(it=L[y].begin();it!=L[y].end();it++){
if (*it == x) {
L[y].erase(it);
break;
}
}
}
if(op==3){
exista=0;
for(it=L[y].begin();it!=L[y].end();it++){
if(*it==x){
exista=1;
break;
}
}
fout<<exista<<"\n";
}
}
return 0;
}