이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
int N;
int doDoor(int door, int s[], int d[], bool fixed[]) {
int upperLimit = N-1;
int lowerLimit = 0;
int b;
for (int i = 0; i < N; i++)
{
if (!fixed[i])
{
s[i] = 1;
}
}
int t = tryCombination(s);
if (t == door) //door is closed on a 1
{
b = 1;
}
else
{
b = 0;
}
for (int i = 0; i < N; i++)
{
if (!fixed[i])
{
s[i] = 1-b;
}
}
while (upperLimit > lowerLimit)
{
int midpoint = (upperLimit + lowerLimit)/2;
for (int i = lowerLimit; i <= midpoint; i++)
{
if (!fixed[i])
{
s[i] = b;
}
}
int x = tryCombination(s);
if (x == door) //case where door closed
{
upperLimit = midpoint;
}
else //case where door opened
{
lowerLimit = midpoint+1;
}
for (int i = lowerLimit; i <= midpoint; i++)
{
if (!fixed[i])
{
s[i] = 1-b;
}
}
}
return lowerLimit;
}
void exploreCave(int n) {
int s[n];
int d[n];
bool fixed[n];
N = n;
for (int i = 0; i < n; i++)
{
s[i] = 0;
d[i] = 0;
fixed[i] = false;
}
for (int i = 0; i < n; i++)
{
int ans = doDoor(i, s, d, fixed);
d[ans] = i;
fixed[ans] = true;
}
answer(s, d);
}
# | 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... |