当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3102:Bee Garden

Special Judge 特殊评判
题目描述

George’s father Ben is fond of bee breeding. He has got a bee garden near his country house and he likes to walk around the garden and gather honey from the hives.

Ben has n hives, located at various points of his garden. Some of them are connected to each other or Ben’s house by straight roads. Ben always walks along the roads, and he never moves from one road to another anywhere except at hives. Neither Ben’s house nor any hive is located on a road.

The roads are organized in such a way, that Ben has exactly one way to get from his house to any hive.

Each week Ben makes a roundtrip. He starts from his house and walks by the roads in such a way that he visits each hive at least once. George once came to see his father and noticed that his father takes the shortest path that allows him to visit each hive and return to his house.

He thought that his father is getting older, so Ben must be getting really tired with all that walking. He decided to build another straight road that would help his father to visit all the hives faster. That road must connect two hives or a hive and Ben’s house. Help George to build the road in such a way that his father needs to walk as short a path as possible to visit all the hives and return home.

Note that neither Ben’s house nor any hive must be located on the new road.

输入解释

The first line of the input file contains n — the number of the hives (1 ≤ n ≤ 200).

Let us consider Ben’s garden located on a Cartesian plane in such a way that his house occupied the point (0, 0). The following n lines contain two integer numbers each — the coordinates of the hives. The coordinates do not exceed 10 000 by their absolute values, no two hives coincide, no hive is located at (0, 0). Let the hives be numbered from 1 to n.

The following n lines describe roads — each road is described by the numbers of hives it connects, Ben’s house is denoted by 0.

输出解释

Output two numbers — the numbers of the hives to be connected by the road. Output 0 instead of hive’s number for Ben’s house.

If there is no straight road that shortens Ben’s roundtrip output “-1”.

输入样例
3
1 0
1 1
0 1
0 2
1 2
1 3
输出样例
0 3

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3102

最后修改于 2020-10-29T06:52:38+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000 65536