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 "speedrun.h"
using namespace std;
const int MAXN = 2e3 + 25;
const int B = 10;
vector <int> adj[MAXN];
vector <int> dd;
void dfs (int pos, int par) {
dd.push_back(pos);
for (int i = 0; i < B; i++) {
if (par & (1 << i)) {
setHint(pos, i + 1, 1);
}
}
for (auto j : adj[pos]) {
if (j == par) continue;
dfs(j, pos);
}
}
void assignHints (int s, int n, int a[], int b[]) {
for (int i = 1; i < n; i++) {
adj[a[i]].push_back(b[i]);
adj[b[i]].push_back(a[i]);
}
setHintLen(20);
dfs(1, 0);
for (int i = 0; i + 1 < n; i++) {
for (int j = 0; j < B; j++) {
if (dd[i + 1] & (1 << j)) {
setHint(dd[i], B + j + 1, 1);
}
}
}
}
void speedrun (int subtask, int n, int x) {
while (x != 1) {
int s = 0;
for (int i = 0; i < B; i++) {
s += (1 << i) * getHint(i + 1);
}
goTo(s); x = s;
}
int y = n - 1;
while (y--) {
int s = 0;
for (int i = 0; i < B; i++) {
s += (1 << i) * getHint(B + i + 1);
}
while (!goTo(s)) {
s = 0;
for (int i = 0; i < B; i++) {
s += (1 << i) * getHint(i + 1);
}
goTo(s);
}
}
}
# | 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... |