UVALive 6859 Points (凸包)
Points
题目链接:
http://acm.hust.edu.cn/vjudge/contest/130303#problem/E
Description
http://7xjob4.com1.z0.glb.clouddn.com/4c9abc79e61f4d543441b48cb0cf6bbeInput
The input file contains several test cases, each of them as described below. The first line contains integer N — the number of points placed by Peter (1 ≤ N ≤ 100000). Each of following N lines contains two integers xi , yi — the point coordinates placed by Peter. The coordinates by absolute value do not exceed 10^6 . Some points can match.Output
For each test case, you need to print one number — the perimeter of the required polygon, on a line by itself. The answer should be printed with accuracy not less than 0.001.Sample Input
``` 1 0 0 2 1 1 1 2 ```Sample Output
``` 5.656 7.656854 ```Source
2016-HUST-线下组队赛-4##题意: 给出网格上的n个点,求一个周长最小的多边形使得所有点都在其内部,且多边形的边要么是网格的边,要么是网格的对角线.
##题解: 由于边只能是网格边或者对角线,在纸上画一下三角形时的情况即可推出结果轮廓. 先对所有点求一个凸包,然后把凸包拓展成为由网格边或对角线组成的多边形,再整体往外扩大1即是最后的结果.
##代码: ``` cpp #include

浙公网安备 33010602011771号