Submission #1271821

#TimeUsernameProblemLanguageResultExecution timeMemory
1271821orgiloogiiCave (IOI13_cave)C++20
0 / 100
151 ms524 KiB
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
void exploreCave(int N) {
	int fin[N] = {0};
	int switches[N] = {0};
	int doors[N] = {0};
	for (int i = 0;i < N;i++) {
		fin[i] = -1;
	}
	for (int i = 0;i < N;i++) {
		for (int j = 0;j < N;j++) {
			if (fin[i] == -1) {
				switches[i] = 0;
			}
			else {
				switches[i] = fin[i];
			}
		}
		int temp = tryCombination(switches);
		int curr;
		if (temp > i || temp == -1) {
			curr = 1;
		}
		else {
			curr = 0;
		}
		int l = 0,r = N, ind;
		while (l + 1 < r) {
			int mid = (l + r) / 2;
			for (int j = 0;j <= mid;j++) {
				if (fin[j] != -1) {
					switches[i] = fin[j];
				}
				else {
					switches[i] = curr^1;
				}
			}
			for (int j = 0;j < N;j++) {
				if (fin[j] != -1) {
					switches[i] = fin[j];
				}
				else {
					switches[i] = curr;
				}
			}
			int t = tryCombination(switches);
			if (t > i || t == -1) {
				r = mid;
				ind = r;
			}
			else {
				l = mid;
			}
		}
	    fin[ind] = curr ^ 1;
	    doors[ind] = i;
	}
	answer(fin, doors);
}
//int main() {
//	
//}
#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...