# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
223822 | kingfran1907 | Nizovi (COI14_nizovi) | C++14 | 6 ms | 384 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 <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int a, b;
int cp(int a, int b) {
printf("cmp %d %d\n", a, b);
fflush(stdout);
int x;
scanf("%d", &x);
return x;
}
void rev(int a, int b) {
printf("reverse %d %d\n", a, b);
fflush(stdout);
}
int main() {
scanf("%d%d", &a, &b);
int ptr = 0;
for (int i = 1; i <= a; i++) {
int lo = a + ptr;
int hi = a + b;
while (lo < hi) {
int mid = (lo + hi + 1) / 2;
if (cp(i + ptr, mid) == -1) lo = mid;
else hi = mid - 1;
}
if (lo == a + ptr) continue;
rev(i + ptr, lo);
rev(i + ptr, lo - (a - i + 1));
rev(lo - (a - i), lo);
ptr += lo - (a - i + 1);
}
printf("end\n");
fflush(stdout);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |