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;
/*
bool jump(int dis) {
return jump(dis);
//tmp += dis;
//tmp %= n;
//return tmp == 0 || tmp > (n / 2);
}
*/
void escape(int n) {
auto amount = [](int src, int dst, int n) {
return (dst - src + n) % n;
};
bool val = jump(0);
if (!val) {
//cout << "debug" << endl;
if (!jump((n + 1) / 2)) {
jump(n - 1); return;
}
}
int cur = 0;
int lo = 0;
int hi = n / 2;
while (lo < hi) {
int mid = (lo + hi + 1) / 2;
int cng = amount(cur, mid, n);
if (!jump(cng)) hi = mid - 1;
else lo = mid;
cur = mid;
//cout << lo << " " << hi << ": " << cur << endl;
}
jump(amount(cur, lo, n));
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |