int order[1<<12];
int o[1<<12];
void init(){
int ps = 1;
for(int mask = 0; mask < (1<<12); mask++){
int cnt = 0;
for(int j = 0; j < 12; j++) if(mask & (1<<j)) cnt++;
if(cnt == 6){
order[mask] = ps;
o[ps] = mask;
ps++;
}
}
}
int flag = 0;
int encode(int n, int x, int y){
if(flag == 0) {init(),flag = 1;}
int xmask = o[x];
int ymask = o[y];
for(int i = 0; i < 12; i++){ //처음으로 달라지는 bit중에 x가 1인 부분
int b1 = xmask & (1<<i);
int b2 = ymask & (1<<i);
if(b1 != b2 && b1 == (1<<i) ) return i + 1;
}
return -1;
}
int order[1<<12],o[1<<12];
void init(){
int ps = 1;
for(int mask = 0; mask < (1<<12); mask++){
int cnt = 0;
for(int j = 0; j < 12; j++) if(mask & (1<<j)) cnt++;
if(cnt == 6){
order[mask] = ps;
o[ps] = mask;
ps++;
}
}
}
int flag = 0;
int decode (int n, int q, int h) {
if(flag == 0) {
flag = 1;
init();
}
int qmask = o[q];
h--;
if(qmask & (1<<h)) return 1;
else return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2289 ms |
124552 KB |
Output is correct - maxh = 12 |
2 |
Correct |
2123 ms |
170192 KB |
Output is correct - maxh = 12 |