#include<algorithm>
#include<string>
using namespace std;
static bool first=1;
static string s[925];
int encode(int n,int x,int y){
if(first){
first=0;
for(int i=0;i<12;i++)
s[1]+=(i<6)?"0":"1";
for(int i=2;i<=920;i++){
s[i]=s[i-1];
next_permutation(s[i].begin(),s[i].end());
}
}
for(int i=0;i<12;i++)
if(s[x][i]=='1'&&s[y][i]=='0')
return i+1;
return -1;
}
#include<algorithm>
#include<string>
using namespace std;
static bool first=1;
static string s[925];
int decode(int n,int q,int h){
if(first){
first=0;
for(int i=0;i<12;i++)
s[1]+=(i<6)?"0":"1";
for(int i=2;i<=920;i++){
s[i]=s[i-1];
next_permutation(s[i].begin(),s[i].end());
}
}
return s[q][--h]=='1';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3885 ms |
47832 KB |
Output is correct - maxh = 12 |
2 |
Correct |
4318 ms |
48072 KB |
Output is correct - maxh = 12 |