# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
742198 |
2023-05-15T18:27:10 Z |
Lukap |
Nizovi (COI14_nizovi) |
C++14 |
|
210 ms |
324 KB |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
int a,b;
int mjesto[MAXN];
int bs (int x, int lo, int hi) {
while (lo < hi) {
int mid = (lo + hi) / 2;
cout << "cmp " << mid + 1 << ' ' << x << "\n";
cout.flush();
int c;
cin >> c;
if (c < 0) lo = mid + 1;
else hi = mid;
}
return lo;
}
int main () {
ios_base::sync_with_stdio (false);
cin.tie (0);
cin >> a >> b;
mjesto[0] = a;
for (int i = 1; i <= a; i++) mjesto[i] = bs (i, a, a + b);
// for (int i = 1; i <= a; i++) cout << i << ' ' << mjesto[i] << "\n";
int lo = 1, hi;
for (int i = 1; i <= a; i++) {
hi = mjesto[i];
int duk = hi - lo + 1, da = a - i + 1, db = duk - da;
if (duk <= 1 || da == 0 || db == 0) {
lo++;
continue;
}
cout << "reverse " << lo << ' ' << hi << "\n";
cout.flush ();
if (db > 1) {
cout << "reverse " << lo << ' ' << lo + db - 1 << "\n";
cout.flush ();
}
if (da > 1) {
cout << "reverse " << hi - da + 1 << ' ' << hi << "\n";
cout.flush ();
}
lo = hi - da + 2;
}
cout << "end";
cout.flush ();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
4 ms |
208 KB |
Output is correct |
3 |
Correct |
5 ms |
208 KB |
Output is correct |
4 |
Correct |
43 ms |
304 KB |
Output is correct |
5 |
Correct |
45 ms |
304 KB |
Output is correct |
6 |
Correct |
55 ms |
300 KB |
Output is correct |
7 |
Correct |
205 ms |
304 KB |
Output is correct |
8 |
Correct |
199 ms |
324 KB |
Output is correct |
9 |
Correct |
148 ms |
300 KB |
Output is correct |
10 |
Correct |
210 ms |
304 KB |
Output is correct |