# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
766337 | zsombor | Cave (IOI13_cave) | C++17 | 0 ms | 0 KiB |
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 <iostream>
#include <vector>
#include "cave.h"
using namespace std;
int n;
vector <int> S;
vector <int> D;
vector <bool> done(5e3);
void open_door(int d) {
for (int i = 0; i < n; i++) if (!done[i]) S[i] = 0;
int o = (tryCombination(S) != d ? 0 : 1), s = 0;
for (int j = 0; j < 13; j++) {
for (int i = 0; i < n; i++) if (!done[i]) S[i] = (i & (1 << j) ? o : 1 - o);
if (tryCombination(S) != d) s += (1 << j);
}
S[s] = o;
D[s] = d;
done[s] = true;
}
void exploreCave(int N) {
n = N;
S.resize(n, 0);
D.resize(n, 0);
for (int i = 0; i < n; i++) open_door(i);
answer(S, D);
}