#include<bits/stdc++.h>
using namespace std;
int yoo[950][12];
int p = 0;
vector<int> wut(12);
void dfs(int d, int br) {
if(d == 12 && br == 6) {
p++;
for(int i = 0; i < 12; i++) {
yoo[p][i] = wut[i];
}
return;
}
else if(d == 12) {
return;
}
dfs(d+1,br);
wut[d] = 1;
dfs(d+1,br+1);
wut[d] = 0;
}
int encode (int n, int x, int y) {
if(p == 0) {
dfs(0,0);
}
for(int i = 0; i < 12; i++) {
if(yoo[x][i] == 1 && yoo[y][i] == 0) {
return i+1;
}
}
}
#include<bits/stdc++.h>
using namespace std;
int yoo[950][12];
int p = 0;
vector<int> wut(12);
void dfs(int d, int br) {
if(d == 12 && br == 6) {
p++;
for(int i = 0; i < 12; i++) {
yoo[p][i] = wut[i];
}
return;
}
else if(d == 12) {
return;
}
dfs(d+1,br);
wut[d] = 1;
dfs(d+1,br+1);
wut[d] = 0;
}
int decode (int n, int q, int h) {
if(p == 0) {
dfs(0,0);
}
return yoo[q][h-1];
}
Compilation message
encoder.cpp: In function 'int encode(int, int, int)':
encoder.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type]
34 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2385 ms |
24244 KB |
Output is correct - maxh = 12 |
2 |
Correct |
2482 ms |
24292 KB |
Output is correct - maxh = 12 |