This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "cycle.h"
#include <bits/stdc++.h>
using namespace std;
void escape(int n) {
if (n == 2) {
jump(1);
return;
}
int cur = 0, lo = 0, hi = n / 2, ans = -1;
if (jump(n - 1)) {
if (!jump(1)) {
jump(n - 1);
return;
}
while (lo <= hi) {
int mid = (lo + hi) >> 1;
bool x = jump(mid <= cur ? cur - mid : n - llabs(cur - mid));
cur = mid;
if (x) ans = mid, lo = mid + 1;
else hi = mid - 1;
}
jump((ans <= cur ? cur - ans : n - llabs(cur - ans)) + n / 2);
} else {
jump(1);
while (lo <= hi) {
int mid = (lo + hi) >> 1;
bool x = jump(mid >= cur ? mid - cur : n - cur + mid);
cur = mid;
if (x) ans = mid, hi = mid - 1;
else lo = mid + 1;
}
jump((ans >= cur ? ans - cur : n - cur + ans) + n / 2);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |