# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
745583 | lukadupli | Nizovi (COI14_nizovi) | C++14 | 49 ms | 288 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 f first
#define s second
using namespace std;
typedef pair<int, int> pii;
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;
void solve(int l, int r){
if(l == 1) return;
if(l < r){
int lo = 1, hi = l - 1;
if(r < A + B){
while(hi > lo){
int mi = (lo + hi) / 2;
if(cmp(mi, r + 1)) hi = mi;
else lo = mi + 1;
}
}
rev(l, r);
solve(r, lo);
}
else{
int lo = l + 1, hi = A + B;
if(r > 1){
while(hi > lo){
int mi = (lo + hi + 1) / 2;
if(cmp(mi, r - 1)) lo = mi;
else hi = mi - 1;
}
}
rev(r, l);
solve(r, lo);
}
}
int main()
{
cin >> A >> B;
rev(1, A);
int pos = A;
if(cmp(A + 1, A)) pos = A + 1;
if(pos == A + B) rev(1, 2);
else solve(pos, pos + 1);
cout << "end" << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |