이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pii;
constexpr int maxn = 5e3 + 5;
int state[maxn] = { 0 }, pos[maxn] = { 0 }; // Pos gives the position of the ith switch, state gives the ith state
bool determined[maxn] = { 0 };
void exploreCave(int n) {
int a, l, u, mid, nmid;
int t;
for (int i = 0; i < n; i++)
{
for (int y = 0; y < n; y++)
{
if (determined[y]) continue;
state[y] = 0;
}
a = tryCombination(state);
if (a == -1) a = n;
if (a > i) {
t = 0;
} else {
t = 1;
}
l = 0, u = n - 1;
while (l != u)
{
nmid = (l + u + 1) >> 1;
for (int y = 0; y < nmid; y++)
{
if (determined[y]) continue;
state[y] = ((t + 1) & 1);
}
for (int y = nmid; y < n; y++)
{
if (determined[y]) continue;
state[y] = t;
}
mid = nmid;
a = tryCombination(state);
if (a == -1) a = n;
if (a > i) {
l = mid;
} else {
u = mid - 1;
}
}
pos[i] = l;
determined[l] = true;
state[l] = t;
}
int pos_output[maxn] = { 0 };
for (int i = 0; i < n; i++)
{
pos_output[pos[i]] = i;
}
answer(state, pos_output);
}
# | 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... |