#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 << "\n";
fflush(stdout);
int ret; cin >> ret;
return ret;
}
void rev(int x, int y){
cout << "reverse" _ x _ y << "\n";
fflush(stdout);
}
int main(){
cin >> a >> b;
int total = a + b, curr = a;
while(curr){
int lo = curr + 1, hi = total;
while(lo < hi){
int mid = (lo + hi) >> 1;
int ans = cmp(curr, mid);
if(ans == -1)
hi = mid;
else if(ans == 1)
lo = mid + 1;
else{
lo = mid;
break;
}
}
rev(curr, lo);
rev(curr, lo - 1);
curr --; total = lo;
}
cout << "end";
fflush(stdout);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
248 KB |
Incorrect |
2 |
Incorrect |
2 ms |
324 KB |
Incorrect |
3 |
Incorrect |
4 ms |
400 KB |
Incorrect |
4 |
Incorrect |
14 ms |
400 KB |
Incorrect |
5 |
Incorrect |
35 ms |
480 KB |
Incorrect |
6 |
Incorrect |
15 ms |
528 KB |
Incorrect |
7 |
Incorrect |
4 ms |
552 KB |
Total cost of reverse commands > 3 000 000 |
8 |
Incorrect |
4 ms |
552 KB |
Total cost of reverse commands > 3 000 000 |
9 |
Incorrect |
4 ms |
552 KB |
Total cost of reverse commands > 3 000 000 |
10 |
Incorrect |
4 ms |
552 KB |
Total cost of reverse commands > 3 000 000 |