← 返回 meta 的题目列表Path with Increasing Node Values in a Tree
类型:online_judge
Given a binary tree, output a path such that each node's value in the path is strictly increasing. The path can start and end at any node, but should be a continuous downward path.
Input:
n: The number of nodes in the tree.
The next n lines will contain the edges of the tree in parent child format. The root node's parent is indicated as -1.
Node values are positive integers and non-repeating.
Output:
Output a path that meets the condition, as node values separated by space. The path should be as long as possible; if there are multiple paths with the same length, output any one of them.
Constraints:
The tree can contain at most 1000 nodes.
Node values are positive, distinct integers.
Example
Input
5
-1 3
3 2
3 1
2 4
1 5