Submission #1356997

#TimeUsernameProblemLanguageResultExecution timeMemory
1356997toast12Lost in the cycle (IOI19_cycle)C++20
100 / 100
0 ms400 KiB
#include "cycle.h"

void escape(int n) {
	if (!jump(0)) jump(n/2);
    int lo = 0, hi = n/2+1;
    int a = 0, b = 0;
    bool poss = true;
    while (lo < hi) {
        int mid = (lo+hi)/2;
        // jump mid steps from the original position
        int res;
        if (poss) res = jump(mid+a);
        else res = jump(mid+b);
        poss = res;
        if (poss) {
            a = -mid;
            b = 0;
            lo = mid+1;
        }
        else {
            a = 0;
            b = n-mid;
            hi = mid;
        }
    }
    if (!poss) jump(n-1);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...