Cod sursa(job #966827)

Utilizator dropsdrop source drops Data 26 iunie 2013 17:00:45
Problema Hashuri Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.81 kb
#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <ctime>
#include <string>
#include <algorithm>
using namespace std;
ifstream ff("hashuri.in");
ofstream gg("hashuri.out");
#define md 19007
vector<int> cc[32][md];

int bit(int x){
	int n=0;
	while(x>0){n++; x-=x&-x;}
	return n;
}

int eok(int k,int p, int x){
	int l=cc[k][p].size();
	for(int i=0;i<l;i++)
	if(cc[k][p][i]==x)return i;
	return -1;
}

int main(){
	int n, op, x, k, p;
	ff >> n;
	for(int i=1;i<=n;i++){
		ff >> op >> x;
		k=bit(x);
		p=x%md;
		if(op==1){ int i=eok(k,p,x); if(i==-1)cc[k][p].push_back(x); } else
		if(op==2){ int i=eok(k,p,x); if(i!=-1)cc[k][p][i]=-1; } else
		if(op==3){ cout << (eok(k,p,x)!=-1) << "\n"; }
	}
	return 0;
}