链接 以下所有文章均转载( http://blog.csdn.net/acmaker/article/details/3176910) 转载请注明出处! 考虑如下的算法, 算法的输入是两个分别有 m 和 n 个顺时针给定顶点的凸多边形 P 和 Q. 计算 P 上 y 坐标值最小的顶点(称为 yminP ) 和 Q 上 y 坐标值最大的顶点(称为 ymaxQ). 为多边形在 yminP 和 ymaxQ 处构造两条切线 LP 和 LQ 使得他们对应的多边形位于他们的右侧. 此时 LP 和 LQ 拥有…
题意: 给你两个凸包,求其最短距离. 解法: POJ 我真的是弄不懂了,也不说一声点就是按顺时针给出的,不用调整点顺序. 还是说数据水了,没出乱给点或给逆时针点的数据呢..我直接默认顺时针给的点居然A了,但是我把给的点求个逆时针凸包,然后再反转一下时针顺序,又WA了.这其中不知道有什么玄机.. 求凸包最短距离还是用旋转卡壳的方法,这里采用的是网上给出的一种方法: 英文版:        http://cgm.cs.mcgill.ca/~orm/mind2p.html 中文翻译版:  http:/…
Bridge Across Islands Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7632   Accepted: 2263   Special Judge Description Thousands of thousands years ago there was a small kingdom located in the middle of the Pacific Ocean. The territory…
/** 旋转卡壳,, **/ #include <iostream> #include <algorithm> #include <cmath> #include <cstdio> using namespace std; ; struct point { double x,y; point(,):x(x),y(y){} }; int dcmp(double x){ if(fabs(x)<eps) ; else ?-:; } point p[],p1[…
Bridge Across Islands Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11539   Accepted: 3395   Special Judge Description Thousands of thousands years ago there was a small kingdom located in the middle of the Pacific Ocean. The territory…
1.Floyd-Warshall 算法 给定一张图,在o(n3)时间内求出任意两点间的最小距离,并可以在求解过程中保存路径 2.Floyd-Warshall 算法概念 这是一个动态规划的算法. 将顶点编号,假设依次为0,1,2-n-1,现在假设DP[i][j][k]表示从i出发,结束于j的满足经过结点的编号至多为k的最短路径,由此性质易知,在易知DP[i][j][k]时,若要求DP[i][j][k+1],有两种情况要考虑: DP[i][j][k+1]所表征的路径经过结点k+1,此时DP[i][j…
Bridge Across Islands Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7202   Accepted: 2113   Special Judge Description Thousands of thousands years ago there was a small kingdom located in the middle of the Pacific Ocean. The territory…
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4199 没想透为啥旋转卡壳跟枚举跑时间差不多.n太小吧! 枚举法: #include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<al…
题目链接:http://poj.org/problem?id=2187 旋转卡壳算法:http://www.cppblog.com/staryjy/archive/2009/11/19/101412.html 或 http://cgm.cs.mcgill.ca/~orm/rotcal.frame.html #include<cstdio> #include<cstring> #include<cmath> #include<iostream> #includ…
题链: http://poj.org/problem?id=3608 题解: 计算几何,求两个凸包间的最小距离,旋转卡壳 两个凸包间的距离,无非下面三种情况: 所以可以基于旋转卡壳的思想,去求最小距离. (分别用i,j表示A,B凸包上枚举到的点,i的初始位置为A上y最小的顶点,j的初始位置为B上y最大的顶点.) 逆时针枚举凸包A的每一条边$\vec{A_iA_{i+1}}$,然后对另一个凸包B逆时针旋转卡壳,找到第一个$\vec{B_{j+1}B_j}\times\vec{A_iA_{i+1}}…