#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
typedef long long ll;
typedef pair<int, int> point;
int a, b;
int cmp(int x, int y){
cout << "cmp" _ x _ y << endl;
fflush(stdout);
int ret; cin >> ret;
return ret;
}
void rev(int x, int y){
if(x == y) return;
cout << "reverse" _ x _ y << endl;
fflush(stdout);
}
int main(){
cin >> a >> b;
int start = 1, end = a + b, len = a;
REP(i, a){
int lo = start + len, hi = end;
if(lo >= hi) continue;
while(lo < hi){
int mid = (lo + hi + 1) >> 1;
int ans = cmp(start, mid);
if(ans <= 0)
hi = mid - 1;
else
lo = mid;
}
if(start >= lo){
assert(a == 0);
start ++; len --;
continue;
}
rev(start, lo);
rev(lo - len + 1, lo);
rev(start, lo - len);
len --; start = lo - len + 1;
}
cout << "end";
fflush(stdout);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Incorrect |
4 ms |
324 KB |
Incorrect |
3 |
Incorrect |
3 ms |
528 KB |
Incorrect |
4 |
Incorrect |
32 ms |
528 KB |
Incorrect |
5 |
Incorrect |
31 ms |
528 KB |
Incorrect |
6 |
Incorrect |
32 ms |
528 KB |
Incorrect |
7 |
Incorrect |
147 ms |
544 KB |
Incorrect |
8 |
Incorrect |
113 ms |
552 KB |
Incorrect |
9 |
Correct |
161 ms |
552 KB |
Output is correct |
10 |
Incorrect |
60 ms |
552 KB |
Total cost of reverse commands > 3 000 000 |