제출 #672753

#제출 시각아이디문제언어결과실행 시간메모리
672753Hacv16동굴 (IOI13_cave)C++17
100 / 100
338 ms504 KiB
#include<bits/stdc++.h>
#include "cave.h"
 
using namespace std;
 
typedef long long ll;
const int MAX = 5e3 + 15;
const int INF = 0x3f3f3f3f;

int S[MAX], D[MAX];
bool mark[MAX];

int findPos(int l, int r, int c, int d){
	if(l == r) return l;
	int m = (l + r) >> 1;

	for(int i = l; i <= m; i++) if(!mark[i]) S[i] = c;
	for(int i = m + 1; i <= r; i++) if(!mark[i]) S[i] = !c;

	int query = tryCombination(S);

	if(query == d) return findPos(m + 1, r, c, d);
	return findPos(l, m, c, d);
}
 
void exploreCave(int n){
	for(int door = 0; door < n; door++){	
		for(int i = 0; i < n; i++)
			if(!mark[i]) S[i] = 0;
 
		int color = (tryCombination(S) == door);
		int pos = findPos(0, n - 1, color, door);
 
		mark[pos] = true;
		D[pos] = door;
		S[pos] = color;
	}
 
	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...