Submission #485183

#TimeUsernameProblemLanguageResultExecution timeMemory
485183rainboyNizovi (COI14_nizovi)C11
100 / 100
188 ms320 KiB
#include <stdio.h> #define N 1000 int cmp(int i, int j) { int x; printf("cmp %d %d\n", i + 1, j + 1), fflush(stdout); scanf("%d", &x); return x; } void rotate(int i, int n, int m) { if (n + m > 1) printf("reverse %d %d\n", i + 1, i + n + m), fflush(stdout); if (m > 1) printf("reverse %d %d\n", i + 1, i + m), fflush(stdout); if (n > 1) printf("reverse %d %d\n", i + m + 1, i + n + m), fflush(stdout); } int main() { static int jj[N]; int na, nb, i, j; scanf("%d%d", &na, &nb); for (i = 0; i < na; i++) { int lower = -1, upper = nb; while (upper - lower > 1) { j = (lower + upper) / 2; if (cmp(na + j, i) < 0) lower = j; else upper = j; } jj[i] = upper; } for (i = 0, j = 0; i < na; i++) if (j < jj[i]) rotate(i + j, na - i, jj[i] - j), j = jj[i]; printf("end\n"), fflush(stdout); return 0; }

Compilation message (stderr)

nizovi.c: In function 'cmp':
nizovi.c:9:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%d", &x);
      |  ^~~~~~~~~~~~~~~
nizovi.c: In function 'main':
nizovi.c:26:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  scanf("%d%d", &na, &nb);
      |  ^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...