#include <bits/stdc++.h>
// #define endl '\n'
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int ll
typedef long long ll;
using namespace std;
const int N = 2e5 + 10;
int n, m;
signed main() {
FAST;
cin >> n >> m;
int idx = n + 1;
int left = n + 1, right = m + n;
while(idx--) {
if(idx == 0) {
cout << "end" << endl;
return 0;
}
int l = left, r = right;
while(l < r) {
int mid = (l + r) / 2;
cout << "cmp " << idx << ' ' << mid << endl;
int x; cin >> x;
if(x == 1) l = mid;
else r = mid - 1;
}
cout << "cmp " << idx << ' ' << l << endl;
int x; cin >> x;
if(x == 1) {
for(int i = idx; i < l; i++) cout << "reverse " << i << ' ' << i + 1 << endl;
right = l - 1;
left = idx;
}
else {
for(int i = idx; i < l - 1; i++) cout << "reverse " << i << ' ' << i + 1 << endl;
right = l - 2;
left = idx;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
788 ms |
296 KB |
Execution killed with signal 13 |
2 |
Runtime error |
786 ms |
296 KB |
Execution killed with signal 13 |
3 |
Runtime error |
717 ms |
292 KB |
Execution killed with signal 13 |
4 |
Runtime error |
526 ms |
296 KB |
Execution killed with signal 13 |
5 |
Runtime error |
831 ms |
296 KB |
Execution killed with signal 13 |
6 |
Runtime error |
692 ms |
304 KB |
Execution killed with signal 13 |
7 |
Runtime error |
696 ms |
304 KB |
Execution killed with signal 13 |
8 |
Runtime error |
583 ms |
316 KB |
Execution killed with signal 13 |
9 |
Runtime error |
589 ms |
328 KB |
Execution killed with signal 13 |
10 |
Runtime error |
635 ms |
316 KB |
Execution killed with signal 13 |