# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
742169 | vanic | Nizovi (COI14_nizovi) | C++14 | 195 ms | 300 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//PROTULIPAC KOD
#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 + 1) / 2;
cout << "cmp " << x << ' ' << mid + a << "\n";
cout.flush();
int c;
cin >> c;
if (c == -1) hi = mid - 1;
else lo = mid;
}
return lo;
}
int main () {
// ios_base::sync_with_stdio (false);
// cin.tie (0);
cin >> a >> b;
for (int i = 1; i <= a; i++) mjesto[i] = bs (i, mjesto[i - 1], b);
int lo = 1, hi;
for (int i = 1; i <= a; i++) {
hi = mjesto[i] + a;
if (hi - lo == a - i || lo >= hi) {
lo++;
continue;
}
cout << "reverse " << lo << ' ' << hi << "\n";
cout.flush ();
if ((hi - lo) - (a - i) > 1) {
cout << "reverse " << lo << ' ' << hi - a + i - 1 << "\n";
cout.flush ();
}
if (i < a) {
cout << "reverse " << hi - a + i << ' ' << hi << "\n";
cout.flush ();
}
lo = max (hi - a + i + 1, lo + 1);
}
cout << "end";
cout.flush ();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |