#include "speedrun.h"
#include "bits/stdc++.h"
using namespace std;
#ifndef EVAL
#include "grader.cpp"
#endif
void assignHints(int subtask, int n, int a[], int b[]) {
vector<vector<int>> edges(n + 1);
vector<int> par(n + 1), tt, nxt(n + 1);
for(int i=1;i<n;i++){
edges[a[i]].push_back(b[i]);
edges[b[i]].push_back(a[i]);
}
function<void(int, int)> dfs = [&](int u, int p){
tt.push_back(u), par[u] = p;
for(auto x : edges[u]){
if(x == p) continue;
dfs(x, u);
}
};
dfs(1, 1);
int p = 0;
for(auto x : tt) nxt[p] = x, p = x;
setHintLen(20);
for(int i=1;i<=n;i++){
for(int j=0;j<10;j++){
setHint(i, j + 1, par[i]>>j&1);
}
for(int j=0;j<10;j++){
setHint(i, j + 10, nxt[i]>>j&1);
}
}
}
int cur;
void dfs(int u, int p = -1){
int x = 0;
for(int j=0;j<10;j++) x |= (getHint(j + 10) << j);
cur = x;
while(goTo(cur)) dfs(cur, u);
if(~p) goTo(p);
}
void speedrun(int subtask, int n, int u) {
while(u != 1){
int par = 0;
for(int j=0;j<10;j++) par |= (getHint(j + 1) << j);
goTo(par), u = par;
}
dfs(u);
}
/*
5
1 2
1 3
2 4
2 5
2
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
87 ms |
548 KB |
Used too many wrong interactions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
194 ms |
860 KB |
Invalid node index to goTo |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
181 ms |
788 KB |
Used too many wrong interactions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
463 ms |
532 KB |
Used too many wrong interactions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
188 ms |
532 KB |
Used too many wrong interactions |
2 |
Halted |
0 ms |
0 KB |
- |