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>
using namespace std;
#define ll long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
#include "cycle.h"
bool test(int x, int jumps, int n) {
int t = (jumps - x + n) % n;
//cout << t << "\n";
return jump(t);
}
void escape(int n) {
if (!jump(0)) {
ll high = n/2;
ll low = 0;
ll cur = 0;
while (high - low > 1) {
ll mid = (high + low) / 2;
//cout << low << " " << mid << " " << high << "\n";
if (test(cur,mid,n) == false) low = mid;
else high = mid;
cur = mid;
}
test(cur,high + n/2,n);
} else {
ll high = n/2+1;
ll low = 0;
ll cur = 0;
while (high - low > 1) {
ll mid = (high + low) / 2;
//cout << low << " " << mid << " " << high << "\n";
if (test(cur,mid,n) == true) low = mid;
else high = mid;
cur = mid;
}
//cout << cur << " " << low << " " << high << "\n";
test(cur,low,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... |