#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
int n,m;
cin >> n >> m;
int cnt=0;
for (int i=1;i<=n;i++){
int x;
int L=cnt+n+1,R=n+m;
while (L < R){
int mid=(L+R+1)/2;
cout << "cmp " << cnt+i << " " << mid << "\n";
fflush(stdout);
cin >> x;
if (x == -1) R=mid-1;
else L=mid;
}
if (L == cnt+n+1){
cout << "cmp " << cnt+i << " " << cnt+n+1 << "\n";
fflush(stdout);
cin >> x;
if (x == -1) continue;
}
int num=L-(cnt+n);
if (cnt+i < cnt+n) cout << "reverse " << cnt+i << " " << cnt+n << "\n";
if (cnt+i < cnt+n) fflush(stdout);
if (cnt+i < L) cout << "reverse " << cnt+i << " " << L << "\n";
if (cnt+i < L) fflush(stdout);
if (cnt+i < cnt+i+num-1) cout << "reverse " << cnt+i << " " << cnt+i+num-1 << "\n";
if (cnt+i < cnt+i+num-1) fflush(stdout);
cnt+=num;
if (cnt == m) break;
}
cout << "end\n";
fflush(stdout);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
2 ms |
208 KB |
Output is correct |
3 |
Correct |
2 ms |
208 KB |
Output is correct |
4 |
Correct |
21 ms |
208 KB |
Output is correct |
5 |
Correct |
27 ms |
208 KB |
Output is correct |
6 |
Correct |
33 ms |
208 KB |
Output is correct |
7 |
Correct |
164 ms |
312 KB |
Output is correct |
8 |
Correct |
151 ms |
208 KB |
Output is correct |
9 |
Correct |
156 ms |
312 KB |
Output is correct |
10 |
Runtime error |
186 ms |
208 KB |
Execution killed with signal 13 |