#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(ll n){
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(ll n){
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));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3753 ms |
24104 KB |
Output is correct - maxh = 12 |
2 |
Correct |
3719 ms |
24436 KB |
Output is correct - maxh = 12 |