Cod sursa(job #1216073)

Utilizator pavlov.ionPavlov Ion pavlov.ion Data 3 august 2014 11:10:39
Problema Hashuri Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 1 kb
#include<fstream>
#include<vector>
#define pb push_back
#define LL long long
#define MOD 666013
#define MAXN 666020
using namespace std;
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
LL N;
int op;
vector<LL> H[MAXN];
//find
vector<LL>::iterator find_value(LL int X){
			vector<LL>::iterator it;		 
			LL V=X%MOD;
			it=H[V].begin();
			while(it!=H[V].end() && *it!=X )
                                          it++;
			return it;
}
void add_value(LL X) {
	     if(find_value(X)==H[X%MOD].end())
	                          H[X%MOD].pb(X);
}
 void erase_value(LL  X) {
 	    if(find_value(X)!=H[X%MOD].end())
		         H[X%MOD].erase(find_value(X));
}					    
int main() {
	LL i,X;
	cin>>N;
	for(i=1;i<=N;i++){
      cin>>op>>X;
      switch(op) {
	  		case 1 : add_value(X);  break;
			case 2 : erase_value(X);  break;
			case 3 :  if(find_value(X)==H[X%MOD].end()) cout<<"0\n";
			                       else cout<<"1\n"; break;
			}
}
return 0;
}