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>
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "cycle.h"
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 gen(std :: chrono :: system_clock :: now().time_since_epoch().count());
void escape(int n) {
int cur = 0;
auto add = [&](int& x, int y) {
x += y;
if (x >= n) x -= n;
if (x < 0) x += n;
};
int L, R;
if (jump(0)) L = 0, R = n / 2;
else L = n / 2 + 1, R = n - 1;
while (L < R) {
int mid = L + R + 1 >> 1;
if (jump((n - cur + mid) % n)) L = mid;
else R = mid - 1;
add(cur, (n - cur + mid) % n);
}
jump((n - cur + L) % n);
}
Compilation message (stderr)
cycle.cpp: In function 'void escape(int)':
cycle.cpp:28:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
28 | int mid = L + R + 1 >> 1;
| ~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |