Submission #97111

#TimeUsernameProblemLanguageResultExecution timeMemory
97111E869120Cave (IOI13_cave)C++14
100 / 100
1334 ms640 KiB
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;

int S[5000], A[5009], B[5009], col[5009];

void exploreCave(int N) {
	for (int i = 0; i < N; i++) col[i] = -1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (col[j] == -1) S[j] = 0;
			else S[j] = col[j];
		}
		int Z = tryCombination(S);
		
		int L = 0, R = N, M, res = 0;
		while (R - L >= 2) {
			M = (L + R) / 2;
			for (int j = 0; j < N; j++) {
				if (col[j] == -1) { if (L <= j && j < M) S[j] = 1; else S[j] = 0; }
				else S[j] = col[j];
			}
			int ZZ = tryCombination(S);
			bool ok1 = true; if (Z == i) ok1 = false;
			bool ok2 = true; if (ZZ == i) ok2 = false;
			
			if (ok1 != ok2) { res = L; R = M; }
			if (ok1 == ok2) { res = M; L = M; }
		}
		if (Z == i) {
			// This switch should be 1.
			col[res] = 1; A[res] = i; B[res] = 1;
		}
		else {
			// THis switch should be 0.
			col[res] = 0; A[res] = i; B[res] = 0;
		}
	}
	answer(B, A);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...