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 <bits/stdc++.h>
#define ii pair <int, int>
#define F first
#define S second
#include "cycle.h"
using namespace std;
const int N = 1e5 + 5;
int n;
int pos = 0;
int absolute_jump(int k) {
    int steps = (k - pos + n) % n;
    pos = k;
    bool ans = jump(steps);
    return ans;
}
void escape(int _n) {
    n = _n;
    bool a = absolute_jump(0), b = absolute_jump(n / 2);
    assert(a || b);
    if (a && b) {
        if (absolute_jump(1))
            absolute_jump(n / 2);
        else
            absolute_jump(0);
        return;
    }
    int left = 0, right = n / 2;
    if (b && !a) {
        std::swap(left, right);
        std::swap(a, b);
    }
    assert(a && !b);
    while (left != right) {
        int dist = (right - left + n) % n;
        int mid = left + (dist + 1) / 2;
        if (absolute_jump(mid))
            left = (mid + n) % n;
        else
            right = (mid - 1 + n) % n;
    }
    absolute_jump(left);
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |