poj 2451 半平面交 板子

2021-09-20 15:28:02 字數 1309 閱讀 4075

poj 2451

半平面,一條直線可以把平面分成兩部分,即稱為半平面

半平面交,即多條直線劃分出的相交的平面的面積

學習大佬的**,清晰易懂,打算當成以後的模板用了

**(基於poj 2451):

#include #include #include #include #include using namespace std;

const double eps = 1e-8;

int n, pn, dq[20005], top, bot;

struct point p[20005];

struct line

} l[20005];

int dblcmp(double k)

double multi(point p0, point p1, point p2)

bool cmp(const line& l1, const line& l2)

void addline(line& l, double x1, double y1, double x2, double y2)

void getintersect(line l1, line l2, point& p)

bool judge(line l0, line l1, line l2)

void halfplaneintersect( )

while (top > bot && judge(l[dq[bot]], l[dq[top]], l[dq[top-1]])) top--;

while (top > bot && judge(l[dq[top]], l[dq[bot]], l[dq[bot+1]])) bot++;

dq[++top] = dq[bot];

for (pn = 0, i = bot; i < top; i++, pn++)

getintersect(l[dq[i+1]], l[dq[i]], p[pn]);

}double getarea()

int main()

addline(l[n++], 0, 0, 10000, 0);

addline(l[n++], 10000, 0, 10000, 10000);

addline(l[n++], 10000, 10000, 0, 10000);

addline(l[n++], 0, 10000, 0, 0);

halfplaneintersect();

printf ("%.1lf\n", getarea());

}return 0;

}

poj 2451 半平面求交

半平面求交,按著zzy 裡的方法對著寫就可以了,這題資料還是比較厚道的 include include includeusing namespace std define eps 1e 8 const int maxn 20005 int dcmp double k struct point poi...

半平面交 板子

poj 2451 敲了個板子,比帶花樹稍微好一些,但是還是很麻煩.寫了點注釋 include include include define point vector const int n 2e4 10 struct vector vector double x,double y double an...

旋轉卡殼 半平面交板子 poj 2079

sampleinput 編輯3 3 42 6 2 75 2 63 9 2 08 0 6 5 1 sampleoutput 編輯0.50 27.00 pragma comment linker,stack 1024000000,1024000000 include include include in...