Submission #28780

#TimeUsernameProblemLanguageResultExecution timeMemory
28780kriiiLR Springboard (FXCUP2_springboard)C++14
1 / 1
3 ms1132 KiB
#include "springboard.h"
 
void Reorder(int N) {
	PutBall((N+1)/2);
	int l,r;
	if (PutBall((N+1)/2) == -1){
		l = (N+1)/2;
		r = N;
	}
	else{
		l = 0;
		r = (N+1)/2 - 1;
	}
 
	while (r - l > 0){
		int step = (r - l + 1) / 2;
		if (r != N) step = N + 1 - step;
 		l = (l + step) % (N+1);
		r = (r + step) % (N+1);
		int d = PutBall(step);
		if (d == -1) r = N;
		else l = 0;
	}
 
	int push = N-l+1;
	if (1 <= push && push <= N) PutBall(push);
}
#Verdict Execution timeMemoryGrader output
Fetching results...