제출 #134445

#제출 시각아이디문제언어결과실행 시간메모리
134445arthurconmy동굴 (IOI13_cave)C++14
0 / 100
209 ms760 KiB
#include <bits/stdc++.h>
using namespace std;

#ifndef ARTHUR_LOCAL
	#include "cave.h"
#endif

void exploreCave(int n)
{
	int D[n]; 
	int S[n];

	for(int i=0; i<n; i++)
	{
		S[i]=0;
		D[i]=0;
	}

	if(n==1)
	{
		if(tryCombination(S)==-1) answer(S,D);
		S[0]=1;
		answer(S,D);
	}

	vector<int> lock(n);

	for(int i=0; i<n; i++)
	{
		int l=0;
		int r=n-1; // door i is controlled by a switch in the range between l and r

		int now=-1;

		while(l<r)
		{
			cout << l << " " << r << endl;

			int cur = tryCombination(S);
			int mid = int((l+r)/2);

			for(int j=l; j<=mid; j++)
			{
				if(!lock[j]) S[j]=1-S[j];
			}

			now = tryCombination(S);

			if(cur==now || (cur!=i && now!=i))
			{
				// cout << cur <<" " << now << " " << i << " " << mid << endl;
				l = mid+1;
			}

			else
			{
				r=mid;
			}
		}

		if(now == i) S[l]=1-S[l];
		lock[l]=1;
		D[l]=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...