이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include<bits/stdc++.h>
using namespace std;
///Binary Search
///Greedy
///Find the position and correct states of the switches
#define debug(x) cout<<#x<<" = "<<x<<endl
int correct[5005];
int pos[5005];
int A[5005];
int locked[5005];
void Init(int n)
{
for(int i=0;i<n;i++){
A[i]=(locked[i]==-1)? 0 : locked[i];
}
}
void findPosition(int id,int n)
{
int L=0,R=n-1;
while(L<R){
int mid=(L+R)/2;
if(correct[id]==0){
for(int i=L;i<mid+1;i++){
A[i]=(locked[i]==-1)? 0 : locked[i];
}
for(int i=mid+1;i<=R;i++){
A[i]=(locked[i]==-1)? 1 : locked[i];
}
}
else{
for(int i=L;i<mid+1;i++){
A[i]=(locked[i]==-1)? 1 : locked[i];
}
for(int i=mid+1;i<=R;i++){
A[i]=(locked[i]==-1)? 0 : locked[i];
}
}
if(tryCombination(A)!=id)
R=mid;
else
L=mid+1;
}
pos[L]=id;
locked[L]=correct[id];
}
void exploreCave(int n) {
memset(locked,-1,sizeof locked);
for(int i=0;i<n;i++){
Init(n);
if(tryCombination(A)!=i)
correct[i]=0;
else
correct[i]=1;
findPosition(i,n);
}
answer(locked,pos);
}
# | 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... |