#include "speedrun.h"
using namespace std;
#include <vector>
#include <set>
#include <iostream>
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);
lin[N + 1] = lin[1];
for(int i = 1; i <= N; i++){
for(int j = 0; j < 10; j++){
setHint(lin[i], j + 1, par[lin[i]] & (1 << j));
setHint(lin[i], j + 1 + 10, lin[i + 1] & (1 << j));
}
}
}
set <int> S;
bool viz[NMAX + 1];
void speedrun(int subtask, int N, int start){
int node = start;
S.insert(node);
int toTry = 0;
while((int)S.size() < N){
//cout << ">> " << node << endl;
viz[node] = true;
int p = 0, x = 0;
for(int i = 1; i <= 10; i++){
p += (1 << (i - 1)) * getHint(i);
x += (1 << (i - 1)) * getHint(i + 10);
}
if(toTry == 0){
toTry = x;
}
if(!viz[toTry] && toTry != 0 && goTo(toTry)){
node = toTry;
toTry = 0;
S.insert(node);
}else{
node = p;
if(node == 0){
return;
}
goTo(node);
S.insert(node);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
117 ms |
1652 KB |
Solution didn't visit every node |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
106 ms |
1396 KB |
Output is correct |
2 |
Incorrect |
98 ms |
1412 KB |
Solution didn't visit every node |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
1412 KB |
Output is correct |
2 |
Correct |
120 ms |
1332 KB |
Output is correct |
3 |
Correct |
95 ms |
1312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
116 ms |
1660 KB |
Solution didn't visit every node |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
91 ms |
1836 KB |
Solution didn't visit every node |
2 |
Halted |
0 ms |
0 KB |
- |