Submission #1348433

#TimeUsernameProblemLanguageResultExecution timeMemory
1348433viduxCave (IOI13_cave)C++17
100 / 100
322 ms520 KiB
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

void exploreCave(int n) {
	int q[n] = {0};
	vi door(n, -1), val(n);
	for (int i = 0; i < n; i++) {
		int l = 0, r = n;
		bool f = 0;
		for (int j = 0; j < n; j++) {
			if (door[j] == -1) q[j] = 1;
			else q[j] = val[j];
		}
		int end = tryCombination(q);
		if (end == -1 || end > i) f = 1;
		bool pr = 0;
		while (l+1 < r) {
			int m = (l+r)/2;
			for (int j = 0; j < n; j++) {
				if (door[j] == -1) q[j] = !f;
				else q[j] = val[j];
			}
			for (int j = l; j < m; j++) {
				if (door[j] == -1) q[j] = f;
				else q[j] = val[j];
			}
			int nend = tryCombination(q);
			if (nend == -1 || nend > i) r = m;
			else l = m;
		}
		door[l] = i;
		val[l] = f;
	}
	int s[n], d[n];
	for (int i = 0; i < n; i++) s[i] = val[i], d[i] = door[i];
	answer(s, d);
}
#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...