Submission #145469

#TimeUsernameProblemLanguageResultExecution timeMemory
145469qkxwsmLost in the cycle (IOI19_cycle)C++14
100 / 100
3 ms380 KiB
#include "cycle.h" #include <bits/stdc++.h> using namespace std; template<class T, class U> void ckmin(T &a, U b) { if (a > b) a = b; } template<class T, class U> void ckmax(T &a, U b) { if (a < b) a = b; } #define MP make_pair #define PB push_back #define LB lower_bound #define UB upper_bound #define fi first #define se second #define FOR(i, a, b) for (auto i = (a); i < (b); i++) #define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--) #define SZ(x) ((int) ((x).size())) #define ALL(x) (x).begin(), (x).end() typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpi; typedef vector<pll> vpl; int N; void solve(int L, int R) { if (L > R) R += N; if (L == R) { if (L != 0) jump(N - L); return; } int mid = ((L + R + 1) >> 1) % N, d = (2 * N + 1 - mid) % N; // cerr << "d = " << d << endl; if (jump(d)) R = mid - 1; else L = mid; L += (d); R += (d); L %= N; R %= N; // cerr << "HI " << L << ' ' << R << endl; solve(L, R); } void escape(int n) { N = n; jump(N - 1); solve(0, N - 1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...