QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 256 MB 満点: 100

#13136. 岛屿

統計

Wen Chen 是一位救援船的船长。他的一项重要任务是每天访问一组岛屿,以检查一切是否正常。Wen 船长从最西端的岛屿出发,向东航行至最东端的岛屿,途中访问部分岛屿;然后进行第二次航行,从最东端的岛屿返回至第一座岛屿,访问剩余的岛屿。在每次航行中,Wen 船长都保持向东(第一次航行)或向西(第二次航行)移动,但为了到达岛屿,他可以根据需要向北或向南移动。唯一的复杂之处在于,有两座特殊的岛屿是 Wen 船长获取船只燃料的地方,因此他必须在两次不同的航行中分别访问这两座岛屿。图 7 展示了这两座粉色的特殊岛屿(1 号和 3 号)以及 Wen 船长可能采取的一条路径。

图 7

在给定每座岛屿的位置以及两座特殊岛屿的编号的情况下,计算访问所有岛屿的两趟航程的最短总长度。

输入格式

输入包含多个测试用例。每个测试用例的数据以一行包含 3 个整数 $n$ ($4 \le n \le 100$)、$b_1$ 和 $b_2$ ($0 < b_1, b_2 < n-1$ 且 $b_1 \neq b_2$) 开始,其中 $n$ 是岛屿的数量(编号为 $0$ 到 $n-1$),$b_1$ 和 $b_2$ 是两座特殊岛屿。接下来有 $n$ 行,包含每座岛屿的整数 $x$ 和 $y$ 坐标 ($0 \le x, y \le 2000$),从岛屿 $0$ 开始。没有两座岛屿具有相同的 $x$ 坐标,且它们按从最西端到最东端的顺序排列(即从最小的 $x$ 坐标到最大的 $x$ 坐标)。

最后一个测试用例后跟一行包含 3 个零的数据。

输出格式

对于每个测试用例,显示两行。第一行包含用例编号和 Wen 船长访问所有岛屿的最短航程长度,四舍五入并保留两位小数。第二行包含以空格分隔的岛屿列表,表示访问顺序,从岛屿 $0$ 和 $1$ 开始,以岛屿 $0$ 结束。每个测试用例都有唯一的解。请遵循样例输出的格式。

样例

输入 1

5 1 3 
1 3
3 4
4 1
7 5
8 3
5 3 2
0 10
3 14
4 7
7 10
8 12
0 0 0

输出 1

Case 1: 18.18
0 1 4 3 2 0 
Case 2: 24.30 
0 1 3 4 2 0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.