# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
478167 | FatihSolak | Nizovi (COI14_nizovi) | C++17 | 222 ms | 220 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;
int ask(int x,int y){
cout << "cmp " << x << " " << y << endl;
int ret;
cin >> ret;
return ret;
}
void rev(int l,int r){
if(l >= r)return;
cout << "reverse " << l << " " << r << endl;
}
int main(){
int a,b;
cin >> a >> b;
int pos = 1;
int cntb = b;
for(int i=1;i<=a && cntb;i++){
int l = pos + a - i + 1, r = a+b;
int cnt = -l;
if(ask(pos,l) != 1){
pos++;
continue;
}
while(l < r){
int m = (l + r + 1)/2;
if(ask(m,pos) != -1){
r = m-1;
}
else l = m;
}
cnt += l;
cntb -= cnt + 1;
rev(pos,l);
rev(pos,pos+cnt);
rev(pos+cnt+1,l);
pos += cnt + 2;
}
cout << "end" << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |