#include "speedrun.h"
#include <bits/stdc++.h>
using namespace std;
void assignHints(int subtask, int n, int a[], int b[]) { /* your solution here */
vector<int> ord, up(n + 1);
vector<vector<int>> adj(n + 1);
for(int i = 1; i < n; i++) {
adj[a[i]].emplace_back(b[i]);
adj[a[i]].emplace_back(b[i]);
}
auto dfs = [&](auto &&self, int u) -> void {
ord.emplace_back(u);
for(const auto &it: adj[u]) if(it != up[u]) {
up[it] = u;
self(self, it);
}
};
dfs(dfs, 1);
setHintLen(20);
auto setHintUp = [&](int u, int val) -> void {
for(int i = 0; i < 10; i++) {
setHint(u, i + 1, val >> i & 1);
}
};
auto setHintNext = [&](int u, int val) -> void {
for(int i = 0; i < 10; i++) {
setHint(u, i + 11, val >> i & 1);
}
};
for(int i = 1; i <= n; i++) {
setHintUp(i, up[i]);
setHintNext(ord[i - 1], ord[i % n]);
}
}
void speedrun(int subtask, int n, int u) { /* your solution here */
auto getHintUp = [&]() -> int {
int res = 0;
for(int i = 0; i < 10; i++) {
res |= getHint(i + 1) << i;
}
return res;
};
auto getHintNext = [&]() -> int {
int res = 0;
for(int i = 0; i < 10; i++) {
res |= getHint(i + 11) << i;
}
return res;
};
while(u != 1) {
u = getHintUp();
goTo(u);
}
do {
int nxt = getHintNext();
while(!goTo(nxt)) {
u = getHintUp();
goTo(u);
}
u = nxt;
} while(u != 1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
344 KB |
Invalid node index for setHint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
105 ms |
860 KB |
Solution didn't visit every node |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Invalid node index for setHint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
344 KB |
Invalid node index for setHint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
344 KB |
Invalid node index for setHint |
2 |
Halted |
0 ms |
0 KB |
- |