Cod sursa(job #1690159)

Utilizator ButmalaiDanButmalai Dan ButmalaiDan Data 14 aprilie 2016 20:30:14
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 1.05 kb
#include<fstream>
using namespace std;
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
typedef struct nod{
        int data;
        bool p;
        nod* next;
   }* hash;
void add(hash &p,int x){
     hash z=new nod;
     z->data=x;
     z->p=1;
     z->next=p;
     p=z;
     }
   hash a[100000];
   int m=20000;
   int n,x,y;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
            cin>>y>>x;
            if(y==1){
                     add(a[x%m],x);                     
                     }
            if(y==2){
                     for(hash z=a[x%m];z!=NULL;z=z->next){
                              if(z->data=x)z->p=0;
                              }
                     }
            if(y==3){bool u =false;
                     for(hash z=a[x%m];z!=NULL;z=z->next){
                              if(z->data=x&&z->p){cout<<"1\n";u=true;}
                              }
                     if(!u)cout<<"0\n";
                     }                  
            
            }      
     return 0;
}