제출 #896691

#제출 시각아이디문제언어결과실행 시간메모리
896691aqxa동굴 (IOI13_cave)C++17
0 / 100
1 ms860 KiB
#include <bits/stdc++.h>
using namespace std;
#include "cave.h"

const int mxn = 5001; 

using ll = long long; 

void exploreCave(int n) {
	int ans[n], need[n]; 
	for (int i = 0; i < n; ++i) {
		need[i] = -1; 
	}

	int t[n]; 
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			t[j] = (need[j] == -1 ? 0 : need[j]); 
		}
		int can = tryCombination(t); 
		if (can == -1) can = n; 
		can = (can > i); 

		int lo = 0, hi = n - 1; 
		while (lo < hi) {
			int mid = (lo + hi) / 2; 
			for (int j = lo; j <= mid; ++j) {
				t[j] = (need[j] == -1 ? t[j] ^ 1 : need[j]); 
			}
			int can2 = tryCombination(t); 
			if (can2 == -1) can2 = n; 
			can2 = (can > i); 
			if (can == can2) {
				lo = mid + 1; 
			} else {
				hi = mid; 
				can = can2; 
			}
		}
		assert(need[lo] == -1); 
		need[lo] = can ^ t[lo] ^ 1; 
		ans[lo] = i; 
	}
	answer(need, ans); 
}
#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...