摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=2823 应该是经典的凸包间最短距离的题目吧。印象中是用旋转卡壳来过的,不过我在hdu水了一下,一个暴力O(n^2)算法直接撸过。 我的做法很简单,就是先判断两个凸包是否相交或包含,然后就用点到线段距离枚举凸包间距离,加了一个遇到距离增加的时候剪枝就过了。代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <vector> 5 #include <algor 阅读全文
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1348 简单二维凸包,直接套用andrew算法得到凸包后求周长,然后加上一个圆周即可。 做的过程中有一个小错误,就是之前已经cin >> n;了,做凸包的时候写成了int n = andrew(pt, n, ch); 从而导致segment fault。以后要注意避免这样的事再次发生。代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <vector> 阅读全文