poj 2187(旋轉卡殼)

2021-08-07 04:45:37 字數 1052 閱讀 4105

傳送門

模板題,求凸包,用旋轉卡殼求出最遠點對。

因為把int弄成double,wa了好幾次,差點對idy大神給的模板失去信心。。。不過事實證明idy的寫法沒問題,orz!

#include

#include

#include

#include

#include

#include

using

namespace

std;

#define eps 1e-10

#define maxn 50002

int n,nxt[maxn];

struct point

friend

bool

operator

<(const point &a,const point &b)

vector operator - (vector a,vector b)

vector operator * (vector a,int s)

vector operator / (vector a,int s)

inline

int dcmp(int x)

inline

int cross(vector a,vector b)

inline

int len(vector a)

inline

int area(point a,point b,point c)

vector

convex(vector

po)

int k=top;

for (int i=n-2;i>=0;--i)

if (n>1) s.pop_back(),--top;

return s;

}int maxdis(vector

p) return ret;

}int main()

printf("%d\n",maxdis(convex(po)));

return

0;}

旋轉卡殼入門 模板題(POJ 2187)

最初接觸旋轉卡殼 應該讀xu n zhu n qi k 是在csu上的一道題 這道題至今沒a,也不知道是是嗎玄學操作,更新 ac了,輸出記得用 f 不過這不重要,重要是學到了新知識!1978年,m.i.shamos s ph.d.的 computational geometry 標誌著電腦科學的這一...

POJ2187 旋轉卡殼求平面最遠點對

分類 計算幾何 2013 02 12 15 23 62人閱讀收藏 舉報旋轉卡殼可以用於求凸包的直徑 寬度,兩個不相交凸包間的最大距離和最小距離等。深度學習旋轉卡殼這裡 題目 beauty contest cpp view plain copy include include include usin...

poj 2187 旋轉卡殼(平面上最遠點對)

題意 給定二維平面上不超過50000個點,求最遠點對距離的平方。思路 由資料量來判斷直接列舉會超時。注意到最遠距離點對必出現在這些點的凸包上,所以可以先求出凸包,然後在凸包上列舉。此法的最壞情況複雜度仍然是n 2的,但是可以ac這道題了。在複雜度意義下的優化是旋轉卡殼 參考 如果qa,qb是凸包上最...