#include "speedrun.h"
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int par[1 << 10];
vector<int> gph[1 << 10];
vector<int> vec;
void dfs(int p, int v) {
vec.push_back(v);
for (int x : gph[v]) if (p != x) {
par[x] = v;
dfs(v, x);
}
}
void assignHints(int subtask, int n, int A[], int B[]) {
for (int i = 1; i < n; i++) {
int u = A[i];
int v = B[i];
gph[u].push_back(v);
gph[v].push_back(u);
}
dfs(0, 1);
vec.push_back(n + 1);
setHintLen(20);
for (int i = 1; i <= n; i++) {
int u = vec[i - 1];
int v = vec[i];
for (int j = 0; j < 10; j++) {
setHint(u, 1 + j, (v >> j & 1));
}
}
for (int i = 2; i <= n; i++) {
int u = i;
int v = par[i];
for (int j = 0; j < 10; j++) {
setHint(u, 11 + j, (v >> j & 1));
}
}
}
int N[1 << 10], P[1 << 10];
bool chc[1 << 10];
void speedrun(int subtask, int n, int v) {
int to = 0, cnt = n;
while (cnt > 0) {
for (int j = 0; j < 10; j++) N[v] |= getHint(1 + j) << j;
for (int j = 0; j < 10; j++) P[v] |= getHint(11 + j) << j;
if (!chc[v]) {
chc[v] = true;
--cnt;
}
if (to == n + 1) {
if (v == 1) {
to = N[v];
}
else {
goTo(P[v]);
v = P[v];
continue;
}
}
if (to == 0) {
to = N[v];
}
if (to == n + 1) continue;
bool f = goTo(to);
if (f) {
v = to;
to = 0;
}
else {
f = goTo(P[v]);
v = P[v];
}
}
}
# | 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... |