半平面交 POJ 3384 Feng Shui

2021-06-23 08:29:51 字數 2871 閱讀 4281

先把每條邊壓縮r的距離,求出半平面交,然後半平面交的最遠點對就是答案了。。。要注意最後的點數只有乙個時的情況,此時兩個圓重合。。但是半平面交求出的平面是不含直線上的點,所以這時半平面交求出的點集為空。。。我的處理方法是壓縮每一條邊的時候少壓縮一點距離,這樣子求出的點不會是空集,注意把握好精度就可以了。。。

#include #include #include #include #include #include #include #include #include #include #include #include #include #define maxn 50005

#define maxm 3000005

#define eps 1e-10

#define mod 998244353

#define inf 999999999

#define lowbit(x) (x&(-x))

#define mp mark_pair

#define ls o<<1

#define rs o<<1 | 1

#define lson o<<1, l, mid

#define rson o<<1 | 1, mid+1, r

#define debug(x) printf("aa x = %d bb\n", x);

//#pragma comment (linker,"/stack:102400000,102400000")

typedef long long ll;

//typedef int ll;

using namespace std;

ll powmod(ll a, ll b)return res;}

void scanf(int &__x)

// head

struct point

bool operator < (const point &a) const

};typedef point vector;

struct line

line(point p, vector v) : p(p), v(v)

bool operator < (const line &l) const

};vector operator + (vector a, vector b)

vector operator - (vector a, vector b)

vector operator * (vector a, double p)

vector operator / (vector a, double p)

int dcmp(double x)

double dot(vector a, vector b)

double length(vector a)

double angle(vector a, vector b)

double cross(vector a, vector b)

double area2(point a, point b, point c)

double polyonarea(point *p, int n)

vector rotate(vector a, double rad)

vector normal(vector a)

bool onleft(line l, point p)

point getintersection(line a, line b)

int convexhull(point *p, int n, point *ch)

int k = m;

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

if(n > 1) m--;

return m;

}point p[maxn];

line q[maxn];

int halfplaneinersection(line* l, int n, point* poly)

if(first < last) p[last-1] = getintersection(q[last-1], q[last]);

} while(first < last && !onleft(q[first], p[last-1])) last--;

if(last - first <= 1) return 0;

p[last] = getintersection(q[last], q[first]);

int m = 0;

for(int i = first; i <= last; i++) poly[m++] = p[i];

return m;

}point po[maxn], poly[maxn];

vector v[maxn], v2[maxn];

line line[maxn];

double r;

int n;

void read(void)

void work(void)

for(int i = 0; i < n; i++) line[i] = line(po[i] + v2[i] * (r - 0.00001), v[i]);

n = halfplaneinersection(line, n, poly);

for(int i = 0; i < n; i++)

for(int j = 0; j < n; j++)

if(dcmp(length(poly[i] - poly[j]) - mx) >= 0)

printf("%.4f %.4f %.4f %.4f\n", poly[ansi].x, poly[ansi].y, poly[ansj].x, poly[ansj].y);

}int main(void)

return 0;

}

POJ 3384 Feng Shui 半平面交

題目給出兩個圓和乙個多邊形 問是否能讓兩個圓在多邊形內。並且覆蓋的面積最大 圓的半徑為r,我們則讓多邊形的每條邊都往內部退r距離。然後求半平面交得出的點集中,最遠的兩個點則是兩圓的圓心即可 include include include include include include include...

POJ 3384 Feng Shui 半平面交

by cxlove 題目 給出乙個凸多邊形的房間,根據風水要求,把兩個圓形地毯鋪在房間裡,不能摺疊,不能切割,可以重疊。問最多能覆蓋多大空間,輸出兩個地毯的圓心座標。多組解輸出其中乙個 題目保證至少可以放入乙個圓,上一題中判斷過在乙個多邊形內是否能放入乙個半徑為r的圓。同樣將多邊形的邊內移r之後,半...

POJ 3384 Feng Shui 半平面交

風水。是一門藝術。我在想要不要看看 周易 葬經 什麼的,等老了還能出去給人算算命,看看陰宅陽宅什麼的,混口飯吃。嘿嘿,扯遠了。題意 給乙個凸多邊形,然後在裡面放兩個半徑為r的圓。問怎麼放能使覆蓋的面積最大 spj 思路 把多邊形的每一條邊向 內 移r的距離,交得乙個新多邊形。在多邊形上找兩個盡量圓的...