Cod sursa(job #1690176)
| Utilizator | Data | 14 aprilie 2016 20:41:48 | |
|---|---|---|---|
| Problema | Hashuri | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.94 kb |
#include<fstream>
using namespace std;
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
typedef struct nod{
int data;
bool p;
nod* next;
}* h;
void add1(h &p,int x){
h z=new nod;
z->data=x;
z->p=1;
z->next=p;
p=z;
}
h a[666615];
int m=666613;
int n,x,y;
int main(){
cin>>n;
for(int i=0;i<n;i++){
cin>>y>>x;
if(y==1)add1(a[x%m],x);
if(y==2)for(h z=a[x%m];z!=NULL;z=z->next){
if(z->data==x)z->p=0;
}
if(y==3){bool u =false;
for(h z=a[x%m];z!=NULL;z=z->next){
if(!u)if(z->data==x&&z->p){cout<<"1\n";u=true;}
}
if(!u)cout<<"0\n";
}
}
return 0;
}
