Pagini recente » Cod sursa (job #2257762) | Cod sursa (job #68717) | Cod sursa (job #2471810) | Cod sursa (job #2505751) | Cod sursa (job #854723)
Cod sursa(job #854723)
#include <fstream>
using namespace std;
bool v[1<<20];
int n, x, y;
class HASH{
int len;
public:
HASH(int len) {
this->len = len;
}
int hash(int n){
int Q = (1 << len) - 1;
int x, y, z;
x = (n << 11) | (n >> (len-11));
y = n >> 7;
z = x ^ y;
return (n ^ z) & Q;
}
};
int main() {
ifstream f("hashuri.in");
ofstream g("hashuri.out");
f >> n;
HASH h(20);
/*
for (int i=0; i<10000; i++)
if (v[h.hash(i)] == true)
g << "nu e bun\n";
else {
//g << h.hash(i) << endl;
v[h.hash(i)] = true;
}
*/
//for (int i=0; i<100; i++)
// g << h.hash(i) << " " << h.hash(i) << endl;
for(int i=0; i<n; i++){
f >> x >> y;
switch (x) {
case 1:
v[h.hash(y)] = true;
break;
case 2:
v[h.hash(y)] = false;
break;
case 3:
g << v[h.hash(y)] << endl;
break;
}
}
return 0;
}