이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
void exploreCave(int n) {
int s[n], known[n], whereto[n];
for(int i = 0; i < n; i++){
known[i] = -1;
whereto[i] = -1;
}
for(int i = 0; i < n; i++){ // minden ajtora
for(int j = 0; j < n; j++){
if(known[j] == -1){
s[j] = 1;
}
else{
s[j] = known[j];
}
}
int g = tryCombination(s);
bool door = (g == -1 || g > i);
int l = 0, r = n - 1;
while(l < r && i < n - 1){
int mid = (l + r) / 2;
for(int j = 0; j < n; j++){
if(known[j] > -1){
s[j] = known[j];
}
else{
if(l <= j && j <= mid){
s[j] = door;
}
else{
s[j] = 1 - door;
}
}
}
int res = tryCombination(s);
if(res == - 1 || res > i){
r = mid;
}
else{
l = mid + 1;
}
}
if(i == n - 1){
for(int j = 0; j < n; j++){
if(whereto[j] == -1){
whereto[j] = n - 1;
known[j] = door;
}
}
}
else{
whereto[l] = i;
known[l] = door;
}
}
answer(known, whereto);
}
# | 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... |