#include"bits/stdc++.h"
using namespace std;
int init = 0;
int g[942];
void __init__ () {
for (int i = 0, j = 0 ; ; i++) {
if (__builtin_popcount(i) == 6) {
g[j++] = i;
if (j == 942) break;
}
}
init = 1;
}
int encode (int n, int x, int y) {
if (!init) {
__init__();
}
for (int i = 0 ; i < 12 ; i++) {
if (g[x] & (1 << i) and !(g[y] & (1 << i))) return i + 1;
}
}
#include"bits/stdc++.h"
using namespace std;
int init = 0;
int g[942];
void __init__ () {
for (int i = 0, j = 0 ; ; i++) {
if (__builtin_popcount(i) == 6) {
g[j++] = i;
if (j == 942) break;
}
}
init = 1;
}
int decode (int n, int q, int h) {
if (!init) {
__init__();
}
return bool(g[q] & (1 << (h-1)));
}
Compilation message
encoder.cpp: In function 'int encode(int, int, int)':
encoder.cpp:22:1: warning: control reaches end of non-void function [-Wreturn-type]
22 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3091 ms |
24300 KB |
Output is correct - maxh = 12 |
2 |
Correct |
3026 ms |
24204 KB |
Output is correct - maxh = 12 |