Submission #233069

#TimeUsernameProblemLanguageResultExecution timeMemory
233069CantfindmeLost in the cycle (IOI19_cycle)C++17
100 / 100
6 ms416 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
#include "cycle.h"

bool test(int x, int jumps, int n) {
	int t = (jumps - x + n) % n;
	//cout << t << "\n";
	return jump(t);
}

void escape(int n) {
	
	if (!jump(0)) {
		ll high = n/2;
		ll low = 0;
		ll cur = 0;
		
		while (high - low > 1) {
			ll mid = (high + low) / 2;
			//cout << low << " " << mid << " " << high << "\n";
			if (test(cur,mid,n) == false) low = mid;
			else high = mid;
			cur = mid;
		}
		
		test(cur,high + n/2,n);	
	} else {
		ll high = n/2+1;
		ll low = 0;
		ll cur = 0;
		
		while (high - low > 1) {
			ll mid = (high + low) / 2;
			//cout << low << " " << mid << " " << high << "\n";
			if (test(cur,mid,n) == true) low = mid;
			else high = mid;
			cur = mid;
		}
		//cout << cur << " " << low << " " << high << "\n";
		test(cur,low,n);
	}
}



#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...