#include "speedrun.h"
using namespace std;
#include <vector>
#include <set>
const int NMAX = 1001;
vector <int> adj[NMAX + 1];
int dfsTime = 0;
int par[NMAX + 1];
int lin[NMAX + 1];
void dfs(int node, int parent){
par[node] = parent;
lin[++dfsTime] = node;
for(int child : adj[node]){
if(child != parent){
dfs(child, node);
}
}
}
void assignHints(int subtask, int N, int A[], int B[]){
for(int i = 1; i <= N - 1; 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++){
for(int j = 0; j < 10; j++){
setHint(lin[i], j, par[lin[i]] & (1 << j));
setHint(lin[i], j + 10, lin[i + 1] & (1 << j));
}
}
}
set <int> S;
void speedrun(int subtask, int N, int start){
int node = start;
S.insert(node);
while((int)S.size() < N){
int p = 0, x = 0;
for(int i = 0; i < 10; i++){
p += (1 << i) * getHint(i);
x += (1 << i) * getHint(i + 10);
}
if(goTo(x)){
node = x;
S.insert(node);
}else{
node = p;
goTo(node);
S.insert(node);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
528 KB |
Invalid bit index for setHint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
536 KB |
Invalid bit index for setHint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
532 KB |
Invalid bit index for setHint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
532 KB |
Invalid bit index for setHint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
532 KB |
Invalid bit index for setHint |
2 |
Halted |
0 ms |
0 KB |
- |