Submission #380668

#TimeUsernameProblemLanguageResultExecution timeMemory
380668ritul_kr_singhCave (IOI13_cave)C++17
0 / 100
324 ms492 KiB
#include "cave.h"

void exploreCave(int N){
	int ans[N], curr[N], D[N];
	for(int &i : ans) i = 2;

	for(int i=0; i<N; ++i){
		for(int j=0; j<N; ++j)
			curr[i] = ans[i]<2 ? ans[i] : 1;

		int currRes = tryCombination(curr);
		bool one = currRes>i or currRes<0;

		int low = 0, high = N-1;
		while(low<high){
			int mid = (low+high)/2;
			for(int j=0; j<N; ++j)
				curr[i] = ans[i]<2 ? ans[i] : ((int)(j<=mid)+(int)!one)%2;
			currRes = tryCombination(curr);
			if(currRes>i or currRes<0) high = mid;
			else low = mid+1;
		}
		ans[low] = one;
		D[low] = i;
	}
	answer(ans, D);
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...