int N = 920, cnt, ba[930];
bool fl=1;
void dfs(int ix, int c0, int c1, int su){
if(ix==12){ ba[cnt++]=su; return; }
if(c0) dfs(ix+1, c0-1, c1, su);
if(c1) dfs(ix+1, c0, c1-1, su|(1<<ix));
}
void init(){
dfs(0, 6, 6, 0);
}
int encode (int n, int x, int y) {
if(fl)init(), fl=0;
for(int i=0; i<12; i++){
if((ba[x-1] & (1<<i)) && (ba[y-1] & (1<<i))==0) return i+1;
}
return 0;
}
int N = 920, cnt, ba[930];
bool fl=1;
void dfs(int ix, int c0, int c1, int su){
if(ix==12){ ba[cnt++]=su; return; }
if(c0) dfs(ix+1, c0-1, c1, su);
if(c1) dfs(ix+1, c0, c1-1, su|(1<<ix));
}
void init(){
dfs(0, 6, 6, 0);
}
int decode (int n, int q, int h) {
if(fl)init(), fl=0;
return (ba[q-1] & (1<<(h-1))) ? 1 : 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1826 ms |
25684 KB |
Output is correct - maxh = 12 |
2 |
Correct |
1935 ms |
25684 KB |
Output is correct - maxh = 12 |