#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));
}
Compilation message
cycle.cpp: In function 'void escape(int)':
cycle.cpp:18:13: error: 'jump' was not declared in this scope
18 | bool val = jump(0);
| ^~~~