이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include<bits/stdc++.h>
using namespace std;
void exploreCave(int n) {
/* ... */
int cur = 0;
int swit[n] = {-1};
int ans[n] = {0};
while(cur<n){
int left = 0,right = n-1;
int val = -1;
while(left<=right){
for (int j = 0;j<2;++j){
int temp[n] = {0};
int mid = (left + right)>>1;
for (int i = 0;i<mid;++i){
if (swit[i]==-1){
temp[i] = j;
}
else temp[i] = ans[i];
}
for (int i = mid;i<n;++i){
if (swit[i]==-1){
temp[i] = j;
}
else{
temp[i] = ans[i];
}
}
int a = tryCombination(temp);
if (a>cur){
val = j;
break;
}
}
assert(val!=-1);
int temp[n] = {0};
int mid = (left + right)>>1;
for (int i = 0;i<mid;++i){
if (swit[i]==-1){
temp[i] = val;
}
else temp[i] = ans[i];
}
for (int i = mid;i<n;++i){
if (swit[i]==-1){
temp[i] = val^1;
}
else temp[i] = ans[i];
}
int a = tryCombination(temp);
if (a>cur){
right = mid-1;
}
else{
left = mid;
}
}
swit[left] = cur;
ans[left] = val;
++cur;
}
answer(ans,swit);
}
# | 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... |