# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
625199 | MilosMilutinovic | Nizovi (COI14_nizovi) | C++14 | 192 ms | 336 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* 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) {
assert(la >= 1 && lb >= 1);
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);
ptr = at[i];
}
}
cout << "end" << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |