Submission #728010

#TimeUsernameProblemLanguageResultExecution timeMemory
728010rainboycmp (balkan11_cmp)C11
100 / 100
1883 ms102184 KiB
#include "cmp.h" #define A 4096 void remember(int a) { for (a += A; a > 1; a >>= 2) bit_set(a); } int compare(int b) { int lower = -1, upper = 6, h; while (upper - lower > 1) { h = (lower + upper) / 2; if (bit_get(A + b >> h * 2)) upper = h; else lower = h; } if (lower == -1) return 0; switch ((A + b >> lower * 2 & 3)) { case 0: return -1; case 1: return bit_get((A + b >> lower * 2) - 1) ? 1 : -1; case 2: return bit_get((A + b >> lower * 2) + 1) ? -1 : 1; case 3: return 1; default: return 0; } }

Compilation message (stderr)

cmp.c: In function 'compare':
cmp.c:15:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   15 |   if (bit_get(A + b >> h * 2))
      |                 ^
cmp.c:22:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   22 |  switch ((A + b >> lower * 2 & 3)) {
      |             ^
cmp.c:26:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   26 |    return bit_get((A + b >> lower * 2) - 1) ? 1 : -1;
      |                      ^
cmp.c:28:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   28 |    return bit_get((A + b >> lower * 2) + 1) ? -1 : 1;
      |                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...