Submission #235332

#TimeUsernameProblemLanguageResultExecution timeMemory
235332crossing0ver동굴 (IOI13_cave)C++17
0 / 100
275 ms632 KiB
#include<bits/stdc++.h>
#include "cave.h"
using namespace std;
int n,type[5005],A[5000],P[5000],oc[5000],C[5000];

int  ask(int S[]) {
	int x =  tryCombination(S);
	if (x == -1) x = n;
	return x;
}

void get_type (int pos) {
	int l = 0, r = n - 1;
	int x = ask(A);
	if (pos <= x) type[pos] = 0,A[pos] = 0;
			else type[pos] = 1, A[pos] = 1;
	
	while (l < r - 1) {
		int m = (l + r)/2;
		for (int i = pos; i <= m; i++) if (!oc[i]) A[i]^=1;
		int x = ask(A);
		if (pos <= x) {
			l = m + 1;		
		}
		else r = m;
		for (int i = pos; i <= m; i++) if (!oc[i]) A[i]^=1;
	}
	if (l == r - 1) {
		if (oc[l]) x = r;
		else if (oc[r]) x = l;
		else {
			A[l]^=1;
			int t = ask(A);
			if (pos <= t) x = r;
			else x = l;
			A[l]^=1; 
		}
	}
	oc[x] = 1;
	C[x] = type[pos]; 
	P[x] = pos;
} 


void exploreCave(int N) {
	n = N;
	for (int i = 0;i < n; i++) {
		get_type(i);
	}
	int S[N],D[N];
	for (int i = 0; i < n; i++)
		S[i] = C[i], 
		D[i] = P[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...