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"
using namespace std;
#include <bits/stdc++.h>
void escape(int n) {
if (n == 2) {
jump(1);
return;
}
int lo = 0, hi = n - 1;
int lst = 0;
while (lo < hi) {
int mid;
if (hi - lo == n - 1)
mid = (lo + hi + 1) / 2;
else
mid = (lo + hi) / 2;
int dist;
int kamo = mid - n / 2;
if (kamo < 0)
kamo += n;
if (kamo >= lst)
dist = kamo - lst;
else
dist = n - lst + kamo;
int ret = jump(dist);
//cout <<lo<<' '<<hi<<' '<<n<<'.'<<mid<<' '<<kamo<<' '<< dist<<' '<<ret<<endl;
if (ret)
hi = mid;
else
lo = mid + 1;
lst = kamo;
}
int dist;
if (lo > lst)
dist = lo - lst;
else
dist = n - lst + lo;
jump(dist);
//cout<<lo<<' '<<dist<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |