# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
230097 | dolphingarlic | Nizovi (COI14_nizovi) | C++14 | 172 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>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
int cmp(int X, int Y) {
cout << "cmp " << X << ' ' << Y << endl;
cin >> X;
return X;
}
void rev(int X, int Y) {
if (X == Y) return;
cout << "reverse " << X << ' ' << Y << endl;
}
int main() {
int A, B;
cin >> A >> B;
for (int A_ptr = 0, B_ptr = 0; A_ptr < A && B_ptr < B; A_ptr++) {
if (cmp(A_ptr + B_ptr + 1, A + B_ptr + 1) != 1) continue;
int l = A + B_ptr + 2, r = A + B + 1;
while (l != r) {
int mid = (l + r) / 2;
if (cmp(A_ptr + B_ptr + 1, mid) != -1) l = mid + 1;
else r = mid;
}
rev(A_ptr + B_ptr + 1, A + B_ptr);
rev(A + B_ptr + 1, l - 1);
rev(A_ptr + B_ptr + 1, l - 1);
B_ptr = l - A - 1;
}
cout << "end" << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |