Submission #41081

#TimeUsernameProblemLanguageResultExecution timeMemory
41081hsb154cmp (balkan11_cmp)C++14
100 / 100
2460 ms92960 KiB
#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 (stderr)

cmp.cpp: In function 'int compare(int)':
cmp.cpp:20:6: warning: unused variable 'ret' [-Wunused-variable]
  int ret;
      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...