poj 1113 graham模板(水平序)

2022-08-20 21:09:14 字數 977 閱讀 2966

這題不多說,裸的模板,graham掃瞄演算法,通過棧比較當前point與棧頂的兩個point是否滿足左轉的關係,不滿足時退棧直到棧空或這滿足時。上**:

/*

memory: 180 kb time: 16 ms

language: c++ result: accepted

by coolwind

*/#include

#include

#include

#include

using

namespace

std;

#define maxn 2000

const

double pi = acos(-1.0

);struct

point

}point[maxn];

intcmpxy(point a, point b)

intxmul(point a, point b, point o)

double

dis(point a, point b)

point stack[maxn];

inttop;

double graham(int n, int

l)

int len =top;

stack[++top] = point[n - 1

];

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

double res = 0

;

for(i = 0; i < top; i ++)

res += dis(stack[i],stack[i + 1

]); res += l * 2.0 *pi;

return

res;

}int

main()

return0;

}

view code

poj 1113 凸包模板

include include include include include include using namespace std define n 1050 define pi acos 1.0 int n,r struct point point operator point b const...

POJ 1113 Wall 凸包 模板題

用不嚴謹的話來講,給定二維平面上的點集,凸包就是將最外層的點連線起來構成的凸多邊型,它能包含點集中所有的點。題意 給出n個點 n 1e3和長度l,求出包圍n個點的最小凸多邊形周長 多邊形距離這n個點的距離 l?若不考慮l 則答案為凸包的周長,考慮條件l,由如下圖形 答案為 凸包周長 以l為半徑的圓的...

計算幾何 poj1113 Wall

進行凸包掃瞄並求面積即可。include include include includeusing namespace std struct point int cmp const void elem1 const void elem2 void add point a,int k double d...