이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <cave.h>
using namespace std;
int n , door[5005] , Comb[5005] ;
/*
int tryCombination(int S[]){
for(int i =0 ; i < n ; i++ )cout << S[i] ;
cout << endl;
int ans ; cin >> ans ; return ans ;
}
void answer(int S[],int D[]){
for(int i =0; i < n ; i++ )cout << S[i]; cout << endl;
for(int i =0; i < n ; i++ )cout << D[i]; cout << endl;
}*/
void Rev(int l , int r ){
for(;l<=r;l++)if(door[l]==-1)Comb[l]=!Comb[l];
}
void findDoor(){
int l =0 , r = n-1 ;
int start = tryCombination(Comb);
//cerr << "findSwitch of "<<start<<endl;
while (l<r && start != -1 ){
int mid = (l+r)/2 ;
Rev(l,mid);
// cerr << l << " " <<mid << " " << r <<endl;
int rep = tryCombination(Comb);
Rev(l,mid);
if( rep == start )l=mid+1;
else r = mid ;
}
assert(l==r||start==-1);
if( l == r ){
door[l]=start;
Comb[l]=!Comb[l];
// cout << "door of "<<l<<" " << start << endl;
}
//cout << "start "<<start<<endl;
}
void exploreCave(int N){
n = N ;
memset(door,-1,sizeof door);
for(int i = 0 ; i < N ; i++ ){
findDoor();
}
for(int i = 0 ; i< N ; i++ ){
if( door[i]==-1){
Comb[i]=!Comb[i];
door[i]=tryCombination(Comb);
Comb[i]=!Comb[i];
}
}
answer(Comb,door);
}
/*
int main(){
cin >> n ;
exploreCave(n);
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |