Submission #143610

#TimeUsernameProblemLanguageResultExecution timeMemory
143610zoomswkLost in the cycle (IOI19_cycle)C++17
100 / 100
2 ms380 KiB
#include "cycle.h"

int calc(int targ, int diff, int n){
    return ((targ-diff)%n+n)%n;
}

void escape(int n) {
    int diff = 0;
    int l=0, r=n-1, res=-1;
    while(l<=r){
        int mid = (l+r)/2;
        int steps = calc(mid, diff, n);
        diff = (diff+steps)%n;
        bool x = jump(steps);
        if(x) res = mid, l = mid+1;
        else r = mid-1;
    }
    jump(calc(res, diff, n));
    return;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...