2022.02.13翻译Looking for Order

Looking for Order
题目(https://acs.jxnu.edu.cn/problem/CF8C)描述:
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 xs, ys. 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.

输出:
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.

样例输入:
0 0
2
1 1
-1 1
样例输出:
8
0 1 2 0 
样例输入:
1 1
3
4 3
3 4
0 0
样例输出:
32
0 1 2 0 3 0 

翻译:
玲娜喜欢一切都井然有序的样子。曾经她上大学的时候注意到寝室里一团糟,她手提包里的东西丢得到处都是。当然她想把东西放回她的手提包里去。问题是她一次只能最多只能拿两个物品,并且不能移动手提包。同时,如果她手上已经拿了一个物品,她只能放在手提包里而不能放在其他地方。

给你在同一个坐标系的手提包的坐标和物品的坐标。已知女孩在两个物品走过的距离等于两个物品坐标的直线距离。要求你找到一个行动顺序,使得女孩回收物品所需的时间最短。

输入:
第一行包含手提包的坐标xs, ys。第二行包含一个整数(1 ≤ n ≤ 24) 表示物品的数量。接下来n行,每行包含一个物品的坐标。所有坐标的绝对值不超过100,且都为不相同的整数。
输出:
第一行输出一个数字,表示回收所有物品所需的最短时间。
第二行输出可能的路线。每个物品用其索引表示(1到n),手提包用0表示。路线必须从手提包开始且从手提包结束。如果这里有多种路线,输出任意一种。
样例输入:
0 0
2
1 1
-1 1
样例输出:
8
0 1 2 0 
样例输入:
1 1
3
4 3
3 4
0 0
样例输出:
32
0 1 2 0 3 0 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值