# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
485183 | rainboy | Nizovi (COI14_nizovi) | C11 | 188 ms | 320 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |