Submission #1189753

#TimeUsernameProblemLanguageResultExecution timeMemory
1189753gygLost in the cycle (IOI19_cycle)C++20
100 / 100
0 ms408 KiB
#include "cycle.h"
#include <bits/stdc++.h>
using namespace std;

void escape(int n) {
	auto ds = [&](int x) { return (x + n) % n; };

	if (n == 2) {
		jump(ds(0 - 1)); return;
	}
	if (jump(0)) {
		int lw = 2, hg = ds(1 - (n + 1) / 2);
		int u = 0;
		while (lw < hg) {
			int md = (lw + hg) / 2;
			int v = md;
			if (!jump(ds(v - u))) hg = md;
			else lw = md + 1;
			u = v;
		}
		jump(ds(0 - u)), jump(lw - 1);
	} else {
		int lw = 1, hg = ds((n + 1) / 2 - 1);
		int u = 0;
		while (lw < hg) {
			int md = (lw + hg) / 2;
			int v = md;
			if (jump(ds(v - u))) hg = md;
			else lw = md + 1;
			u = v;
		}
		jump(ds(0 - u)), jump(lw), jump(ds(0 - (n + 1) / 2)); 
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...