#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));
}
}
}
void speedrun(int subtask, int N, int start){
int node = start;
for(int i = 1; i <= N - 1; i++){
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);
}
while(!goTo(x)){
node = p;
goTo(node);
p = 0;
for(int i = 1; i <= 10; i++){
p += (1 << (i - 1)) * getHint(i);
}
}
node = x;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
124 ms |
1652 KB |
Output is correct |
2 |
Correct |
96 ms |
1560 KB |
Output is correct |
3 |
Correct |
125 ms |
1316 KB |
Output is correct |
4 |
Correct |
115 ms |
1552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
122 ms |
1648 KB |
Output is correct |
2 |
Correct |
112 ms |
1400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
131 ms |
1140 KB |
Output is correct |
2 |
Correct |
93 ms |
1808 KB |
Output is correct |
3 |
Correct |
97 ms |
1140 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
133 ms |
1140 KB |
Output is correct |
2 |
Correct |
92 ms |
1388 KB |
Output is correct |
3 |
Correct |
119 ms |
1816 KB |
Output is correct |
4 |
Correct |
113 ms |
1392 KB |
Output is correct |
5 |
Correct |
109 ms |
1812 KB |
Output is correct |
6 |
Correct |
134 ms |
1564 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
107 ms |
1136 KB |
Output is correct |
2 |
Correct |
88 ms |
1396 KB |
Output is correct |
3 |
Correct |
121 ms |
1912 KB |
Output is correct |
4 |
Correct |
113 ms |
1156 KB |
Output is correct |
5 |
Correct |
105 ms |
1660 KB |
Output is correct |
6 |
Correct |
111 ms |
1396 KB |
Output is correct |
7 |
Correct |
93 ms |
1412 KB |
Output is correct |