제출 #672824

#제출 시각아이디문제언어결과실행 시간메모리
672824mseebacherCave (IOI13_cave)C++17
12 / 100
474 ms384 KiB
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
void exploreCave(int n){
	int pos[n];
	int switched[n];
	for(int i = 0;i<n;i++) 
	{
		pos[i] = 0;
		switched[i] = 0;
	}
	
	vector<bool> vis(n,0);
	for(int i = 0;i<n;i++){
		for(int j = 0;j<n;j++){
			if(!vis[j])
				switched[j] = 0;
		}
		int l = 0;
		int r = n-1;
		int x = tryCombination(switched);
		int mid = 0;
		int flag = 0;
		if(x == i){
			flag = 1;
		}
		while(l<r){
			mid = (l+r) /2;
			for(int h = l;h<=mid;h++){
				if(!vis[h])
					switched[h] = flag;
			}
			for(int h = 0;h<l;h++){
				if(!vis[h])
					switched[h] = !flag;
			}
			for(int h = mid+1;h<n;h++){
				if(!vis[h])
					switched[h] = !flag;
			}
			x = tryCombination(switched);
			if(x == i)
				l = mid+1;
			else r = mid;
		}
		vis[r] = 1;
		pos[r] = i;
		switched[i] = flag; 
	}
	answer(switched,pos);
}
#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...