Tree Embedding
Time limit1sMemory limit1024 MB
Given a weighted tree, assign each vertex a vector of at most 16 integers so the max coordinate gap between two vectors equals their tree distance.
- Level
Hard9 of 10
- Topics
- Tree, Divide and conquer, Math
- Solved
- No attempts yet
Problem
bobo has a tree with vertices. bobo wants to assign an -dimensional vector to each vertex so that for all vertices and , .
is the length of the shortest path between and . For vectors and , the inner product is
Input
The first line contains an integer ().
Vertices are numbered .
Each of the following lines contains three integers , , and , meaning there is an edge between vertices and with length (, ).
Output
The first line contains an integer , the dimension of the vectors ().
Each of the following lines contains integers, the vector . Each coordinate must be in .
Any valid solution is accepted.