Cod sursa(job #1066851)

Utilizator IonMosnoiIon Mosnoi IonMosnoi Data 25 decembrie 2013 18:34:02
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.76 kb
#include<fstream>
#include<vector>
#define pb push_back
using namespace std;

const int maxn = 10000;
const int M = 10000;

  vector <int> hash[maxn]; 

void adauga(int a){
	hash[a%M].pb(a/M);
}
void sterge(int a){
	for(int j=0;j<hash[a%M].size();j++){
		if(hash[a%M][j] == a/M){
			hash[a%M][j]=-1;
			break;
		}
	}
}
int check(int a){
		for(int j=0;j<hash[a%M].size();j++){
		if(hash[a%M][j] == a/M){
		return 1;
			break;
		}
	}	
	return 0;
}
main(){
  ifstream fin("hashuri.in");
  ofstream fout("hashuri.out"); 
  
 int n,a,b;

  fin>>n;
  for(int i=1;i<=n;i++){
  	fin>>a>>b;
  	if(a==1){
  		adauga(b);
  	}else if(a==2){
  		sterge(b);
  	}else{
  		fout<<check(b)<<"\n";
  	}
  }
  
 
    fin.close(); fout.close();
  
}