Submission #544751

#TimeUsernameProblemLanguageResultExecution timeMemory
544751rainboyColors (BOI20_colors)C11
100 / 100
4 ms300 KiB
#include <stdio.h> int query(long long i) { int x; printf("? %lld\n", i), fflush(stdout); scanf("%d", &x); return x; } int main() { long long n, m, l, r, c; int turn; scanf("%lld", &n); l = 0; for (m = n - 1; m > 0; m /= 4) l -= (m + 1) / 2; l = 1 - l, r = l, m = n - 1, turn = 0; query(r); c = 1; for (m = n - 1; m > 0; m /= 2, turn ^= 1) if (turn == 0) { if (query(l -= (m + 1) / 2)) r -= (m + 1) / 2, m--; else c += (m + 1) / 2; } else { if (query(r += (m + 1) / 2)) l += (m + 1) / 2, m--; else c += (m + 1) / 2; } printf("= %lld\n", c); return 0; }

Compilation message (stderr)

Colors.c: In function 'query':
Colors.c:7:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  scanf("%d", &x);
      |  ^~~~~~~~~~~~~~~
Colors.c: In function 'main':
Colors.c:15:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  scanf("%lld", &n);
      |  ^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...