luogu#P2775. 机器人路径规划问题(疑似错题)

    ID: 1796 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>O2优化启发式迭代加深搜索 IDA*网络流与线性规划 24 题

机器人路径规划问题(疑似错题)

Background

Directly passing a problem by siphoning testdata and “table-based” solutions (hardcoding lookup tables) is cheating; once discovered, you will be brown-named.

This problem does not guarantee that there exists a solution that works for arbitrary data within this problem’s constraints. Because the testdata are weak, a program that passes this problem may be incorrect (e.g., with wrong time complexity or without correctness guarantees). The problem statement and testdata are for reference only. This problem does not accept additional hack testdata.

This is a faulty problem. You are not recommended to attempt or submit to this problem. More details about this type of problem.

Problem Description

Robot Rob can move freely on a tree-shaped path. Given the start ss and the end tt on the tree TT, Rob needs to move from ss to tt. There are several movable obstacles on TT. 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 ss to tt. For the given tree TT and the distribution of obstacles in TT, compute the minimal number of moves for the robot to go from ss to tt.

Input Format

The first line contains three positive integers nn, ss and tt, denoting the number of vertices of the tree TT, the index of the start ss, and the index of the end tt, respectively.

The next nn lines correspond to the vertices of TT numbered 0,1,,n10,1,\cdots,n-1. In each line, the first integer hh indicates the initial state of the vertex: when h=1h = 1, the vertex is empty; when h=0h = 0, the vertex is occupied, containing exactly one obstacle. The second number kk indicates that there are kk vertices adjacent to this vertex. The following kk 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 10001000.

Translated by ChatGPT 5