제출 #1163343

#제출 시각아이디문제언어결과실행 시간메모리
1163343boclobanchat동굴 (IOI13_cave)C++20
0 / 100
14 ms328 KiB
#include"cave.h"
#include<bits/stdc++.h>
using namespace std;
int tryCombination(int S[]);
void exploreCave(int N)
{
	int pos[N],A[N],ans[N];
	bool ck[N];
	for(int i=0;i<N;i++) ck[i]=true,pos[i]=0;
	int f=tryCombination(pos);
	for(int i=0;i<N;i++)
	{
		int l=0,r=N-1,p=-1,fn,pp;
		while(l<=r)
		{
			int mid=(l+r)/2;
			while(p<mid) p++,pos[p]^=ck[p];
			while(p>mid) pos[p]^=ck[p],p--;
			int res=tryCombination(pos);
			if(res!=f) r=mid-1,fn=res,pp=mid;
			else l=mid+1;
		}
		while(p>=0) pos[p]^=ck[p],p--;
		ck[pp]=false;
		if(f<fn) ans[pp]=pos[pp]=true;
		else ans[pp]=pos[pp]=false;
		A[i]=pp;
	}
	answer(ans,A);
}
#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...