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>
using namespace std;
#include "speedrun.h"
vector <int> adj[2001];
int parent[2001];
vector <int> ord;
void dfs (int pos, int par) {
for (int i = 1; i <= 10; i++) {
if (par & (1 << (i - 1))) {
setHint(pos, i, 1);
}
}
ord.push_back(pos);
for (auto j : adj[pos]) {
if (j != par) dfs(j, pos);
}
}
void assignHints (int subtask, int n, int a[], int b[]) {
if (n == 1) return;
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 = 1; i < n; i++) {
int x = ord[i];
for (int j = 1; j <= 10; j++) {
if (x & (1 << (j - 1))) {
setHint(ord[i - 1], j + 10, 1);
}
}
}
}
int getpar () {
int ret = 0;
for (int i = 10; i >= 1; i--) {
ret *= 2; ret += getHint(i);
}
return ret;
}
int getnext () {
int ret = 0;
for (int i = 20; i >= 11; i--) {
ret *= 2; ret += getHint(i);
}
return ret;
}
void speedrun (int subtask, int n, int start) {
while (start > 1) {
start = getpar();
goTo(start);
}
for (int i = 2; i <= n; i++) {
int x = getnext();
while (goTo(x) == 0) goTo(getpar());
}
}
# | 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... |