#P2775. 机器人路径规划问题(疑似错题)
机器人路径规划问题(疑似错题)
Description
Robot Rob can move freely on a tree-shaped path. Given the start and the end on the tree , Rob needs to move from to . There are several movable obstacles on . Because the path is narrow, no two objects can occupy the same position at the same time. In each step, you may move either an obstacle or the robot to an adjacent empty vertex. Design an efficient algorithm to minimize the number of moves needed to move the robot from to . For the given tree and the distribution of obstacles in , compute the minimal number of moves for the robot to go from to .
Input Format
The first line contains three positive integers , and , denoting the number of vertices of the tree , the index of the start , and the index of the end , respectively.
The next lines correspond to the vertices of numbered . In each line, the first integer indicates the initial state of the vertex: when , the vertex is empty; when , the vertex is occupied, containing exactly one obstacle. The second number indicates that there are vertices adjacent to this vertex. The following numbers are the indices of the adjacent vertices.
Output Format
Output the minimal number of moves computed. If the robot cannot be moved from the start to the end, output No solution!.
5 0 3
1 1 2
1 1 2
1 3 0 1 3
0 2 2 4
1 1 3
3
Hint
All numbers that appear in the problem are less than .
Translated by ChatGPT 5
京公网安备 11011102002149号