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 <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
void assignHints(int subtask, int N, int A[], int B[]) {
setHintLen(20);
vector<vector<int>> G(N + 1);
for (int i = 1; i < N; ++i) {
G[A[i]].push_back(B[i]);
G[B[i]].push_back(A[i]);
}
int last = 0;
function<void(int, int)> dfs = [&](int u, int p) {
if (last) for (int i = 0; i < 10; ++i) setHint(last, i + 1, (u >> i) & 1);
last = u;
for (int i = 0; i < 10; ++i) setHint(u, i + 11, (p >> i) & 1);
for (int v : G[u]) if (v != p) dfs(v, u);
};
dfs(1, 0);
setHint(last, 1, 1);
}
void speedrun(int subtask, int N, int start) {
int cur = start;
while (true) {
int target = 0;
for (int i = 10; i >= 1; --i) target = target * 2 + getHint(i);
if (target == cur) break;
cout << cur << ' ' << target << endl;
while (!goTo(target)) {
int par = 0;
for (int i = 20; i >= 11; --i) par = par * 2 + getHint(i);
goTo(par);
}
}
}
# | 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... |