#include <bits/stdc++.h>
using namespace std;
int a,b;
int ask(int x,int y){
cout << "cmp " << x << " " << y << endl;
int ret;
cin >> ret;
return ret;
}
int tot = 0;
void rev(int l,int r){
tot += r - l +1;
while(!(tot <= 3000000));
while(!(r <= a+b && l > 0 && l <= r));
cout << "reverse " << l << " " << r << endl;
}
int main(){
cin >> a >> b;
int pos = 1;
for(int i=1;i<=a && pos < a + b;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;
rev(pos,l);
rev(pos,pos+cnt);
rev(pos+cnt+1,l);
pos += cnt + 2;
}
cout << "end" << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
2 ms |
200 KB |
Output is correct |
3 |
Correct |
2 ms |
200 KB |
Output is correct |
4 |
Correct |
21 ms |
200 KB |
Output is correct |
5 |
Runtime error |
10 ms |
200 KB |
Execution killed with signal 13 |
6 |
Correct |
13 ms |
200 KB |
Output is correct |
7 |
Correct |
191 ms |
256 KB |
Output is correct |
8 |
Correct |
183 ms |
200 KB |
Output is correct |
9 |
Correct |
162 ms |
200 KB |
Output is correct |
10 |
Correct |
231 ms |
200 KB |
Output is correct |