# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
41081 | 2018-02-12T14:36:54 Z | hsb154 | cmp (balkan11_cmp) | C++14 | 2460 ms | 92960 KB |
#include "cmp.h" void remember(int n) { int mask = 7 << 9; int me = 0; int shift = 9; for (int i = 0; i<4; i++) { me = me * 8 + ((mask&n) >> shift)+1; bit_set(me); shift -= 3; mask >>= 3; } } int compare(int b) { int ret; int mask = 7 << 9; int shift = 9; int me = 0; int left = 1; int right = 4; int mid = (left + right) / 2; int saveHeight=-1; while (1) { mask = 7 << 9; shift = 9; me = 0; if (left > right) break; mid = (left + right) / 2; for (int i = 0; i < mid;i++) { me = me * 8 + ((mask&b) >> shift) + 1; shift -= 3; mask >>= 3; } if (bit_get(me)) { left = mid + 1; } else { saveHeight = mid; right = mid - 1; } } if (saveHeight == -1) return 0; me = 0; mask = 7 << 9; shift = 9; for (int i = 0; i < saveHeight; i++) { left = me * 8 + 1; right = me * 8 + 8; me = me * 8 + ((mask&b) >> shift) + 1; shift -= 3; mask >>= 3; } if (me - left < right - me) { for (int m = me - 1; m >= left; m--) { if (bit_get(m) == 1) return 1; } return -1; } else { for (int m = me + 1; m <= right; m++) { if (bit_get(m) == 1) return -1; } return 1; } /* for(int i=0;i<4;i++){ int temp_me = me * 8 + ((mask&b) >> shift) + 1; if(bit_get(temp_me)==0){ int left = me * 8 + 1; int right = me * 8 + 8; if (temp_me - left < right - temp_me) { for (int m = temp_me - 1; m >= left; m--) { if (bit_get(m) == 1) return 1; } return -1; } else { for (int m = temp_me +1; m <= right; m++) { if (bit_get(m) == 1) return -1; } return 1; } } me = temp_me; mask >>= 3; shift -= 3; } */ return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2460 ms | 92960 KB | Output is correct - maxAccess = 10, score = 100 |