Poj2187 凸包求最大距離

2021-08-03 21:40:06 字數 1461 閱讀 2180

凸包+暴力求解,注意n==0,和n==1的情況;

#include #include#include#include#include#include#include#define maxn 50000+10

using namespace std;

typedef struct point

point;

int n;

point map[maxn],p;

double dis(point p1,point p2)// 求兩點的距離

int cross(point a,point b,point c) //三角形面積||判斷兩直線的方向

bool cmp(point p1,point p2)

void sort_cir()

point;

int n;

point map[maxn],p;

double dis(point p1,point p2)// 求兩點的距離

int cross(point a,point b,point c) //三角形面積||判斷兩直線的方向

int dis2(point a,point b)

int muli(point p1,point p2,point p3)

bool cmp(point p1,point p2)

vectors;

void graham()

cout<>n&&n)

};typedef point vector;

//向量使用點作為表示方法 結構相同 為了**清晰定義巨集加以區別

const double eps = 1e-8;

int dcmp(double x) //三態函式 處理與double零有關的精度問題

//向量運算

vector operator + (vector a, vector b)

vector operator - (vector a, vector b)

vector operator * (vector a, double p)

vector operator / (vector a, double p)

bool operator == (const vector& a, const vector& b)

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

int k = m;

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

if(n > 1) m--;

return m;

}void rc(point ch,int n)

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

}int main()

{ point p[maxn],ch[maxn];

int n,j,i;

while(~scanf("%d",&n))

{for(i=0;i

poj 2187 凸包求最遠距離

這裡很明顯不能直接暴力 50000 50000 我們要知道最遠的兩點一定是凸包上的頂點,所以首先構造凸包,然後列舉找出最遠距離,注意這裡是平方!還要注意n 2的情況,直接求距離 include include include include include include include inclu...

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...

poj 2187 凸包 最大點對距

題目大意就是最大點對距,最大點對距的兩端點一定是凸包頂點,所以找出形成凸包所需要的最少頂點,然後遍歷找出最大點對距。對凸包演算法的詳細講解 include include using namespace std struct point point vertex 500000 res 500000 ...