#include<bits/stdc++.h>
using namespace std;
vector<int> ans1(12);
vector<int> ans2(12);
vector<int> wut(12);
int p = 0;
void dfs(int d, int x, int y, int br) {
if(d == 12 && br == 6) {
p++;
if(x == p) {
for(int i = 0; i < 12; i++) {
ans1[i] = wut[i];
}
}
if(y == p) {
for(int i = 0; i < 12; i++) {
ans2[i] = wut[i];
}
}
return;
}
else if(d == 12) {
return;
}
dfs(d+1,x,y,br);
wut[d] = 1;
dfs(d+1,x,y,br+1);
wut[d] = 0;
}
int encode (int n, int x, int y) {
p = 0;
dfs(0,x,y,0);
for(int i = 0; i < 12; i++) {
if(ans2[i] == 0 && ans1[i] == 1) {
return i+1;
}
}
}
#include<bits/stdc++.h>
using namespace std;
vector<int> ans(12);
vector<int> wut(12);
int p = 0;
void dude(int d, int x, int br) {
if(d == 12 && br == 6) {
p++;
if(x == p) {
for(int i = 0; i < 12; i++) {
ans[i] = wut[i];
}
}
return;
}
else if(d == 12) {
return;
}
dude(d+1,x,br);
wut[d] = 1;
dude(d+1,x,br+1);
wut[d] = 0;
}
int decode (int n, int q, int h) {
p = 0;
h--;
dude(0,q,0);
return ans[h];
}
Compilation message
encoder.cpp: In function 'int encode(int, int, int)':
encoder.cpp:41:1: warning: control reaches end of non-void function [-Wreturn-type]
41 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
7086 ms |
4368 KB |
Time limit exceeded |
2 |
Execution timed out |
7096 ms |
4404 KB |
Time limit exceeded |