# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
44768 |
2018-04-06T06:31:56 Z |
tjd229 |
cmp (balkan11_cmp) |
C++11 |
|
2385 ms |
99656 KB |
#include "cmp.h"
void remember(int n) {
//edit this
int i;
int a = n;
int r[4];
for (i = 4; i--; ){
r[i] = a % 8;
a >>= 3;
}
//[3]:per 8 [2]:per 64 [1]:per 64*8 [0]:per 4096
for (a = 1, i = 0; i < 4;i++){
a = (a<<3) + r[i];
bit_set(a);
}
}
int compare(int b) {
//edit this
int i;
int r[4];
int pt[4];
int a = b;
for (i = 4; i--;){
r[i] = a % 8;
a >>=3;
}
for (a = 1, i = 0; i < 4; i++){
pt[i]=a = (a << 3) + r[i];
}
//bs
int bnd = 0;
int lo = 0;
int hi = 3;
//while (bit_get(pt[bnd])){
// bnd++;
// if (bnd == 4) return 0;
//}
while (lo <= hi){
int mid = (lo + hi) >> 1;
if (bit_get(pt[mid])) lo = mid + 1;
else hi = mid - 1;
}
bnd = lo;
if (bnd == 4) return 0;
if (r[bnd] == 7) return 1;
if (r[bnd] == 0) return -1;
i = 0;
if (r[bnd] > 3) i += 4;
for (a = i + 3; i <= a; i++){ //0~3 or 4~7
if (r[bnd] == i) continue;
if (bit_get(pt[bnd] - r[bnd] + i))
return r[bnd] < i ? -1 : 1;
}
return r[bnd]>3? 1:-1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2385 ms |
99656 KB |
Output is correct - maxAccess = 10, score = 100 |