CF8C.Looking for Order
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Girl Lena likes it when everything is in order, and looks for order everywhere. Once she was getting ready for the University and noticed that the room was in a mess — all the objects from her handbag were thrown about the room. Of course, she wanted to put them back into her handbag. The problem is that the girl cannot carry more than two objects at a time, and cannot move the handbag. Also, if he has taken an object, she cannot put it anywhere except her handbag — her inherent sense of order does not let her do so.
You are given the coordinates of the handbag and the coordinates of the objects in some Сartesian coordinate system. It is known that the girl covers the distance between any two objects in the time equal to the squared length of the segment between the points of the objects. It is also known that initially the coordinates of the girl and the handbag are the same. You are asked to find such an order of actions, that the girl can put all the objects back into her handbag in a minimum time period.
女孩莉娜喜欢一切井然有序,并处处追寻秩序。有一次,她正准备去大学,发现房间一片混乱——她手提包里的所有物品都被散落在房间各处。当然,她想把这些物品重新放回手提包里。问题在于:这个女孩一次最多只能携带两件物品,且无法移动手提包;此外,一旦她拿起某件物品,就只能将其放入手提包中——她与生俱来的秩序感不允许她将物品放在其他任何地方。
给定手提包及各物品在某个笛卡尔坐标系中的坐标。已知:女孩在任意两点之间移动所需的时间等于这两点间线段长度的平方。同时已知:初始时刻,女孩与手提包位于同一坐标位置。你的任务是找出一种操作顺序,使得女孩能以最短总时间将所有物品全部放回手提包中。
输入格式
The first line of the input file contains the handbag's coordinates x__s, y__s. The second line contains number n (1 ≤ n ≤ 24) — the amount of objects the girl has. The following n lines contain the objects' coordinates. All the coordinates do not exceed 100 in absolute value. All the given positions are different. All the numbers are integer.
输入文件的第一行包含手提包的坐标 xs, ys。第二行包含一个整数 n(1 ≤ n ≤ 24),表示女孩拥有的物品数量。接下来的 n 行每行包含一个物品的坐标。所有坐标的绝对值均不超过 100。所有给定的位置互不相同。所有数字均为整数。
输出格式
In the first line output the only number — the minimum time the girl needs to put the objects into her handbag.
In the second line output the possible optimum way for Lena. Each object in the input is described by its index number (from 1 to n), the handbag's point is described by number 0. The path should start and end in the handbag's point. If there are several optimal paths, print any of them.
第一行输出一个数字——莉娜将物品放入手提包所需的最短时间。
第二行输出一种可能的最优路径。输入中的每个物品用其索引号(从 1 到 n)表示,手提包的位置用数字 0 表示。该路径应始于手提包位置,并终于手提包位置。若存在多个最优路径,输出任意一个即可。
输入输出样例
输入#1
0 0 2 1 1 -1 1
输出#1
8 0 1 2 0
输入#2
1 1 3 4 3 3 4 0 0
输出#2
32 0 1 2 0 3 0
输入解题思路,AI测评打分。不知道怎么写?