Submission #992910

#TimeUsernameProblemLanguageResultExecution timeMemory
992910vqpahmad동굴 (IOI13_cave)C++14
100 / 100
346 ms604 KiB
#include<bits/stdc++.h>
#include "cave.h"
using namespace std;
#ifdef ONPC
#include"debug.h"
#else
#define debug(...) 42
#endif
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
const int mod = 1e9 + 7;
const int MAXN = 1e6 + 15;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
int ask(int s[]){
	return tryCombination(s);
}

void exploreCave(int n) {
	int s[n] = {};
	int b[n] = {};
	int p[n] = {};
	for (int i = 0; i < n; i++) b[i] = -1;

	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			s[j] = (b[j] == -1 ? 0 : b[j]);
		}
		int f = ask(s);
		if (f == -1) f = n;
		int v = !(f > i);
		int lo = -1, hi = n - 1;
		while (hi - lo > 1){
			int mi = (lo + hi) / 2;
			for (int j = 0; j <= mi; j++){
				s[j] = (b[j] == -1 ? v : b[j]);
			}
			for (int j = mi + 1; j < n; j++){
				s[j] = (b[j] == -1 ? (v^1) : b[j]);
			}
			f = ask(s);
			if (f == -1) f = n;
			if (f > i){
				hi = mi;
			} else {
				lo = mi;
			}
		}
		b[hi] = v;
		p[hi] = i;
	}
	answer(b, p);
	return ;
}
#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...