# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
745581 | lukadupli | Nizovi (COI14_nizovi) | C++14 | 87 ms | 292 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;
bool cmp(int a, int b){
cout << "cmp " << a << ' ' << b << endl;
int x;
cin >> x;
return x == -1;
}
void rev(int l, int r){
if(l == r) return;
cout << "reverse " << l << ' ' << r << endl;
}
int A, B;
int main()
{
cin >> A >> B;
rev(1, A);
int pos = A;
if(cmp(A + 1, A)) pos = A + 1;
while(pos > 1){
int l = 1, r = pos;
while(r > l){
int m = (l + r) / 2;
if(cmp(m, pos + 1)) r = m;
else l = m + 1;
}
rev(l, pos);
pos = l;
if(pos == 1) break;
l = pos; r = A + B;
while(r > l){
int m = (l + r + 1) / 2;
if(cmp(m, pos - 1)) l = m;
else r = m - 1;
}
rev(pos, r);
rev(pos - 1, r);
pos--;
}
cout << "end" << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |