#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int encode (int n, int x, int y) {
if (!v.size()) {
for (int i = 0; i < (1<<12); i++) {
int cnt = 0;
for (int j = 0; j < 12; j++) if (i&(1<<j)) cnt++;
if (cnt == 6) v.push_back(i);
}
}
for (int k = 0; k < 12; k++) {
if ((v[x-1]&(1<<k)) && !(v[y-1]&(1<<k))) return k+1;
} return 0;
}
#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int decode (int n, int q, int h) {
if (!v.size()) {
for (int i = 0; i < (1<<12); i++) {
int cnt = 0;
for (int j = 0; j < 12; j++) if (i&(1<<j)) cnt++;
if (cnt == 6) v.push_back(i);
}
}
return (v[q-1]&(1<<(h-1))) != 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3029 ms |
24216 KB |
Output is correct - maxh = 12 |
2 |
Correct |
3023 ms |
24192 KB |
Output is correct - maxh = 12 |