#include <iostream>
#include <vector>
using namespace std;
#include "speedrun.h"
const int NMAX = 1000;
vector<int> edges[NMAX + 1];
int parent[NMAX + 1];
int nextInOrder[NMAX + 2];
int orderTime;
void dfs(int node, int par) {
parent[node] = par;
nextInOrder[orderTime++] = node;
for(auto child : edges[node]) {
if(child != par)
dfs(child, node);
}
}
void assignHints (int subtask , int N, int A[], int B[]) {
for(int i = 1; i <= N - 1; i++) {
edges[A[i]].push_back(B[i]);
edges[B[i]].push_back(A[i]);
}
int l = 10;
setHintLen(2 * l);
orderTime = 1;
dfs(1, 0);
nextInOrder[N + 1] = 1;
for(int i = 1; i <= N; i++) {
for(int bit = 0; bit < l; bit++) {
setHint(nextInOrder[i], bit + 1, parent[nextInOrder[i]] & (1 << bit));
setHint(nextInOrder[i], bit + l + 1, nextInOrder[i + 1] & (1 << bit));
}
}
}
void speedrun(int subtask , int N, int start ) {
int node = start;
int l = getLength ();
for(int i = 1; i <= N - 1; i++) {
int par, nextNode;
par = nextNode = 0;
for(int bit = 0; bit < l; bit++) {
par += (1 << bit) * getHint(bit + 1);
nextNode += (1 << bit) * getHint(bit + 1 + l);
}
while(goTo(nextNode) == false) {
node = par;
goTo(node);
par = 0;
for(int bit = 0; bit < l; bit++)
par += (1 << bit) * getHint(bit + 1);
}
node = nextNode;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
106 ms |
880 KB |
Invalid bit index for getHint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
106 ms |
908 KB |
Invalid bit index for getHint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
83 ms |
880 KB |
Invalid bit index for getHint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
86 ms |
884 KB |
Invalid bit index for getHint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
90 ms |
884 KB |
Invalid bit index for getHint |
2 |
Halted |
0 ms |
0 KB |
- |