/**
* author: wxhtzdy
* created: 09.08.2022 16:41:55
**/
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int na, nb;
cin >> na >> nb;
auto Ask = [&](int i, int j) {
cout << "cmp " << i << " " << j << endl;
int x;
cin >> x;
return x;
};
vector<int> at(na);
for (int i = 0; i < na; i++) {
int low = 1, high = nb;
while (low <= high) {
int mid = low + high >> 1;
if (Ask(i + 1, na + mid) >= 0) {
at[i] = mid;
low = mid + 1;
} else {
high = mid - 1;
}
}
}
auto Reverse = [&](int pos, int la, int lb) {
cout << "reverse " << pos << " " << pos + la + lb - 1 << endl;
if (la > 1) {
cout << "reverse " << pos + lb << " " << pos + la + lb - 1 << endl;
}
if (lb > 1) {
cout << "reverse " << pos << " " << pos + lb - 1 << endl;
}
};
int ptr = 0;
for (int i = 0; i < na; i++) {
if (ptr < at[i]) {
Reverse(i + 1 + ptr, na - i, at[i] - ptr);
}
}
cout << "end" << endl;
return 0;
}
Compilation message
nizovi.cpp: In function 'int main()':
nizovi.cpp:24:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
24 | int mid = low + high >> 1;
| ~~~~^~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
312 KB |
Incorrect |
2 |
Incorrect |
3 ms |
208 KB |
Incorrect |
3 |
Incorrect |
3 ms |
312 KB |
Incorrect |
4 |
Incorrect |
42 ms |
296 KB |
Incorrect |
5 |
Incorrect |
42 ms |
300 KB |
Incorrect |
6 |
Incorrect |
46 ms |
208 KB |
Incorrect |
7 |
Incorrect |
69 ms |
304 KB |
Total cost of reverse commands > 3 000 000 |
8 |
Incorrect |
155 ms |
308 KB |
Total cost of reverse commands > 3 000 000 |
9 |
Incorrect |
175 ms |
308 KB |
Total cost of reverse commands > 3 000 000 |
10 |
Incorrect |
169 ms |
300 KB |
Total cost of reverse commands > 3 000 000 |