제출 #791264

#제출 시각아이디문제언어결과실행 시간메모리
791264Bula동굴 (IOI13_cave)C++14
13 / 100
155 ms536 KiB
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
//#define int ll
const ll mod=1e9+7,N=5005;
int c[N],d[N],t[N],cur[N];
 
void exploreCave(int n){
	for(int i=0;i<n;i++){
		c[i] = 1;
		t[i] = 0;
	}
	int p = tryCombination(c);
	if (p == -1) p = n;
	for (int i = 0 ; i < n - 1 ; i++){
		if(p > i){
			int l = 0, r = n - 1;
			while(l < r){
				int m = (l + r) / 2;
				for(int j = 0; j < n; j++) cur[j] = c[j];
				for(int j = l ; j <= m ; j++){
					if(t[j] == 0) cur[j] = 0;
				}
				int k = tryCombination(cur);
				if(k == -1) k = n;
				if(k == i) r = m;
				else l = m + 1;
			}
			t[l] = 1;
			c[l] = 1;
			d[l] = i;
		}
		if(p <= i){
			int l = 0, r = n - 1;
			while(l < r){
				int m = (l + r) / 2;
				for(int j = 0; j < n; j++) cur[j] = c[j];
				for(int j = l ; j <= m ; j++){
					if(t[j] == 0) cur[j] = 0;
				}
				int k = tryCombination(cur);
				if(k == -1) k = n;
				if(k > i) r = m;
				else l = m + 1;
			}
			t[l] = 1;
			c[l] = 0;
			d[l] = i;
		}
	}
	
	int x = n;
	for(int i=0;i<n;i++){
		if(t[i] == 0){
			x = i;
		}
	}
	d[x] = n - 1;
	int k = tryCombination(c);
	if(k == -1) c[x] = 1;
	else c[x] = 0;
	answer(c,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...