This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "cave.h"
// #include "grader.c"
using namespace std;
void exploreCave(int N) {
vector<bool> do_not_change(N);
int answers[N] = {};
int state[N] = {};
for (int door = 0; door < N; door++)
{
int lever_number = 0;
// either (true -> open) or (false -> open)
bool open_state;
for (int i = 0; i < N; i++) {
if (do_not_change[i]) {
continue;
}
state[i] = true;
}
{
int dist = tryCombination(state);
open_state = (dist == -1) || dist > door;
}
// loop over every bit in the number of the levers
// for (int i = 4096; i > 0; i /= 2) {
for (int i = 2; i > 0; i /= 2) {
// set the levers like this
for (int j = 0; j < N; j++) {
if (do_not_change[j]) {
continue;
}
state[j] = (((j & i) == 0) xor (open_state)) ? 1 : 0;
}
int dist = tryCombination(state);
if (dist == -1 || dist > door) {
// success
lever_number += i;
}
}
answers[lever_number] = door;
state[lever_number] = open_state;
do_not_change[lever_number] = true;
}
answer(state, answers);
}
# | 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... |