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 "speedrun.h"
#include <bits/stdc++.h>
using namespace std;
void assignHints(int, int n, int *U, int *V) {
setHintLen(20);
vector<vector<int>> G(n + 1);
for (int i = 1; i < n; i++) {
G[U[i]].push_back(V[i]), G[V[i]].push_back(U[i]);
}
int lst = 0;
function<void(int, int)> dfs = [&](int u, int fa) {
if (lst) for (int i = 0; i < 10; i++) setHint(lst, i + 1, u >> i & 1);
lst = u;
for (int i = 0; i < 10; i++) setHint(u, i + 11, fa >> i & 1);
for (int v : G[u]) if (v ^ fa) dfs(v, u);
};
dfs(1, 0);
setHint(lst, 1, 1);
}
void speedrun(int, int n, int s) {
while (1) {
int fa = 0;
for (int i = 0; i < 10; i++) if (getHint(i + 1)) fa |= 1 << i;
if (s == fa) break;
while (!goTo(fa)) {
int nxt = 0;
for (int i = 0; i < 10; i++) if (getHint(i + 11)) nxt |= 1 << i;
goTo(nxt);
}
}
}
# | 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... |