# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
387850 | Nima_Naderi | Question (Grader is different from the original contest) (CEOI14_question_grader) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MXN = 1e4 + 10;
const ll LOG = 12;
ll Mask[MXN]; bool gen = 0;
void prep(){
gen = 1; ll ts = 1;
for(int mask = 0; mask < (1LL << 12); mask ++){
ll pc = __builtin_popcountll(mask);
if(pc != 6) continue;
Mask[ts ++] = mask;
if(ts > n) break;
}
}
int encode (int n, int x, int y) {
if(!gen) prep(n);
int h = 0, xr = Mask[x] ^ Mask[y];
for(int i = 0; i < LOG; i ++){
if((xr >> i) & 1LL){
if((Mask[x] >> i) & 1LL){
h = i;
h ++;
return h;
}
}
}
return -1;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MXN = 1e4 + 10;
const ll LOG = 12;
ll Mask[MXN]; bool gen = 0;
void prep(){
gen = 1; ll ts = 1;
for(int mask = 0; mask < (1LL << 12); mask ++){
ll pc = __builtin_popcountll(mask);
if(pc != 6) continue;
Mask[ts ++] = mask;
if(ts > n) break;
}
}
int decode (int n, int q, int h) {
if(!gen) prep(n);
h --;
q = Mask[q];
return (((q >> h) & 1LL));
}