UOJ 242 UR 16 破壞蛋糕

2021-07-22 10:43:09 字數 3282 閱讀 2871

一句話題意:平面上有 n+1條直線,前 n 條直線把平面分成許多塊,這些塊有些面積有限,有些面積無限,而第 n+1 條直線不經過前 n 條直線的交點,且一定不和前 n 條直線中的任意一條平行,求第 n+1 條直線被前 n 條直線劃分成的 n+1 段中哪些在面積有限的塊裡,哪些在面積無限的塊裡。

保證第 n+1 條直線不經過前 n 條直線的交點,且一定不和前 n 條直線中的任意一條平行或重合。

保證第 n+1 條直線不與 x 軸垂直,且對於第 n+1 條直線有 x1

,3≤n

≤105 ,保證−2

×106≤

x1,y

1,x2

,y2≤

2×106

。對於點o所在的區域,所有直線改為左側為o的有向直線,原題變為每次調整一條直線的方向,維護半平面交的區域是否有限,也就是是否有兩條相鄰的有向直線轉角

>

π ,這可以用set解決

大佬的題解:

#include

using

namespace

std;

#define for(i,n) for(int i=1;i<=n;i++)

#define fork(i,k,n) for(int i=k;i<=n;i++)

#define rep(i,n) for(int i=0;i#define ford(i,n) for(int i=n;i;i--)

#define repd(i,n) for(int i=n;i>=0;i--)

#define forp(x) for(int p=pre[x];p;p=next[p])

#define forpiter(x) for(int &p=iter[x];p;p=next[p])

#define lson (x<<1)

#define rson ((x<<1)+1)

#define mem(a) memset(a,0,sizeof(a));

#define memi(a) memset(a,0x3f,sizeof(a));

#define memi(a) memset(a,128,sizeof(a));

#define memx(a,b) memset(a,b,sizeof(a));

#define inf (0x3f3f3f3f)

#define f (1000000007)

#define pb push_back

#define mp make_pair

#define fi first

#define se second

#define vi vector

#define pi pair

#define si(a) ((a).size())

#define pr(kcase,ans) printf("case #%d: %lld\n",kcase,ans);

#define pri(a,n) for(i,n-1) cout<#define pri2d(a,n,m) for(i,n)

ll add(ll a,ll b)

ll sub(ll a,ll b)

void upd(ll &a,ll b)

int read()

while(isdigit(ch))

return x*f;

} ll sqr(ll a)

ld sqr(ld a)

double sqr(double a)

const

double eps=1e-10;

int dcmp(double x)

ld pi = 3.141592653589793238462643383;

class p

friend

long

double dis2(p a,p b)

friend

long

double dot(p a,p b)

friend

long

double length(p a)

friend

long

double angle(p a,p b)

friend p operator- (p a,p b)

friend p operator+ (p a,p b)

friend p operator* (p a,double p)

friend p operator/ (p a,double p)

friend

bool

operator

< (const p& a,const p& b)

}; p read_point()

bool

operator==(const p& a,const p& b)

typedef p v;

double cross(v a,v b)

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

p getlineintersection(p p,v v,p q,v w)

struct line

line(p p,v v):p(p),v(v)

bool

operator

<(const line & l) const

void reverse()

};#define maxn (100005+10)

line l,s[maxn];

int n;

ld a[maxn];

multiset

s;multiset

::iterator it,_it;

vector

< pairint> > ins;

int cnt = 0;

int check(ld a,ld b,bool flag=0)

void insert(ld c)

void delete(ld c)

void work()

putchar("01"[cnt==0]);

puts("");

}int main()

l=s[n+1];

for(i,n)

sort(all(ins));

cnt+=check(*--s.end(),*s.begin(),1);

for(it=s.begin(),_it=++s.begin();_it!=s.end();it=_it,_it++)

work();

return

0;}

UOJ 242 UR 16 破壞蛋糕

傳送門 貌似出題人給的方法一點都不友好qwq 那個如果乙個平面是有限的,那麼它被分為兩部分,這兩部分都是有限的。假設我們要求的那條直線是y軸 不是也可以轉 那麼考慮對直線左右分別計算平面是否有限。就直線右側而言,我們把交點按照順序排好。交點ya 和yb 之間的區間對應平面是有限的,當且僅當存在yc ...

uoj 242 UR 16 破壞蛋糕

uoj 考慮把那最後一條直線拎出來,並且旋轉到和 y 軸平行 其他直線同時一起旋轉 然後它和其他直線相交形成 n 1 個區間,現在要知道這些區間是否處在乙個面積有限的區域 可以發現一段在有限區域當且僅當區間的兩側區域都是有限的.所以對線的兩側分開考慮,先考慮左邊,如果直線的乙個區間旁邊的區域有限,那...

UOJ 192 UR 14 最強跳蚤

題目鏈結 暑期課第二天 樹上問題高階 具體內容看筆記部落格吧 題意n個節點的樹t 邊有邊權w 求滿足 u,v 上所有邊權乘積為完全平方數的路徑有多少條 看到 所有邊權乘積為完全平方數 想到完全平方數的特殊性 就是分解質因數後 質因數指數都為偶數 然後就想到分解邊權質因數 判質路徑邊權奇偶性 後者由於...