#include <bits/stdc++.h>
using namespace std;
namespace {
vector<int> cnd;
}
int encode(int n, int x, int y) {
if (!cnd.size()) {
for (int i = 1; cnd.size() < 920; ++i) {
if (__builtin_popcount(i) == 6) {
cnd.push_back(i);
}
}
}
--x, --y;
for (int i = 0; i < 12; ++i) {
if (cnd[x] >> i & 1 && !(cnd[y] >> i & 1)) {
return i + 1;
}
}
assert(0);
return -1;
}
#include <bits/stdc++.h>
using namespace std;
namespace {
vector<int> cnd;
}
int decode(int n, int q, int h) {
if (!cnd.size()) {
for (int i = 1; cnd.size() < 920; ++i) {
if (__builtin_popcount(i) == 6) {
cnd.push_back(i);
}
}
}
q = cnd[q - 1];
return q >> (h - 1) & 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2331 ms |
24564 KB |
Output is correct - maxh = 12 |
2 |
Correct |
2314 ms |
24560 KB |
Output is correct - maxh = 12 |