poj 2187 凸包求最遠距離

2021-05-26 20:49:32 字數 770 閱讀 8317

這裡很明顯不能直接暴力(50000*50000)=。=

我們要知道最遠的兩點一定是凸包上的頂點,所以首先構造凸包,然後列舉找出最遠距離,注意這裡是平方!還要注意n==2的情況,直接求距離

#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;

#define ll long long

#define pi acos(-1)

#define n 50010

#define inf 9999999999

#define eps 1e-8

int n;

int top;

struct point

p[n],stck[n],p0;

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

int dis(point a,point b)

bool cmp(point a,point b)

top+=1;

return ;

}void solve()

printf("%d\n",max);

}int main()

{ // freopen("a.txt","r",stdin);

while(scanf("%d",&n)!=eof)

{int i,j,k;

for(i=0;i

Poj2187 凸包求最大距離

凸包 暴力求解,注意n 0,和n 1的情況 include include include include include include include define maxn 50000 10 using namespace std typedef struct point point int ...

poj2187 凸包問題

pseudo code graham scan algorithm input a set of pointss select the rightmost lowest point p0 ins.sortsangularly about p0 as a center.for ties,discard...

poj2187 凸包直徑模板

include include include include using namespace std define inf 50005 struct node node point inf int n,s inf top double cross node a,node b,node c doub...