제출 #1289937

#제출 시각아이디문제언어결과실행 시간메모리
1289937muhammad-ahmad동굴 (IOI13_cave)C++20
100 / 100
451 ms524 KiB
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;

void exploreCave(int N) {
	int x, st[N], D[N], Q[N];
	for (int i = 0; i < N; i++) st[i] = D[i] = -1;
	for (int i = 0; i < N; i++){
		int cur = 0;
		for (int j = 0; j < N; j++){
			if (st[j] == -1) Q[j] = 0;
			else Q[j] = st[j];
		}
		x = tryCombination(Q);
		if (x <= i && x != -1) cur = 1;
		int l = 0, r = N;
		while (r - l > 1){
			int m = (l + r - 1) / 2;
			for (int j = 0; j < N; j++){
				if (st[j] != -1) Q[j] = st[j];
				else if (j >= l && j <= m) Q[j] = cur;
				else Q[j] = !cur;
			}
			x = tryCombination(Q);
			if (x > i or x == -1) r = m + 1;
			else l = m + 1;
		}
		st[l] = cur;
		D[l] = i;	
	}
	
	answer(st, D);
	
}

// int main(){
	// exploreCave(2);
// }
#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...