이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
const int M = 5000;
bool found[M + 2];
int Switch[M + 2], query[M + 2], s[M + 2], d[M + 2];
int ask (int n, int mij, int state) {
for (int i = 0; i < n; i++)
if (found[i])
query[i] = Switch[i];
else if (i <= mij)
query[i] = state;
else
query[i] = 1 - state;
return tryCombination(query);
}
void exploreCave (int n) {
for (int i = 0; i < n; i++) {
bool state;
int value = ask(n, n - 1, 1);
if (value > i || value == -1)
state = 1;
else
state = 0;
int st = 0, dr = n - 1, poz = 0;
while (st <= dr) {
int mij = (st + dr) / 2;
int aux = ask(n, mij, state);
if (aux > i || aux == -1) {
dr = mij - 1;
poz = mij;
}
else
st = mij + 1;
}
d[poz] = i;
s[poz] = state;
found[poz] = 1;
Switch[poz] = state;
}
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... |