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

建议使用的浏览器:

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

2678:Mothy

题目描述
Mothy is a small moth. Mothy and his mother are placed on a very old pair of jeans. Because the jeans are very old they are covered with patches. Sometimes the patches overlap each other. Every patch is a convex polygon and is made by some material different from cotton. Mothy wants to go to his mother in the fastest possible way. He cannot move without eating and because of his age he cannot eat anything except jeans and cotton thread. Despite his age Mothy is very intelligent, he can move following precise coordinates but he is unable to compute them. Write a program that calculates the length of the minimal path from the position of Mothy to the position of his mother. Mothy must be able to pass through this path. Consider that the pair of old jeans is placed on a plane surface and is big enough. Mothy can move only at the surface of the jeans because he is not big enough to penetrate through them.
Because Mothy is so small he should be considered as a point. Mothy also can move on the edges of any of the patches because they are sewed with cotton threads. Mothy can move on common edges but cannot be on top of any patch.
输入解释
The first line of input contains a single integer T indicating the number of test cases. Each test case starts with number N of patches, and four integer numbers – the coordinates X and Y of Mothy’s position and coordinates U and V of his mother’s position, separated by white spaces (-10000 <= X, Y, U, V <= 10000). Each patch is described on a separate line starting with the number of vertices and followed by a pair of integer coordinates (-10000 <= Xi, Yi <= 10000) for each of the vertices of the patch, separated by white spaces. The total number of vertices of polygons will not exceed 300.
输出解释
For each of the test cases program has to output on a separate line the length of the shortest path between Mothy and his mother. The result should be rounded to 3 digits after the decimal point. The program has to output -1 if Mothy cannot reach his mother.
输入样例
2
1 0 0 4 3
3 1 1 4 4 1 4
2 0 0 5 5
4 1 0 4 0 4 1 1 2
3 3 3 4 4 5 2
输出样例
5.000
7.236

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

源链接: POJ-2678

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

共提交 0

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