hdu1558計算幾何加並查集

2022-08-17 23:15:18 字數 1881 閱讀 9575

不知道杭電題目分類是咋分的,這題我是在「匹配」裡找到的,太假了。這明顯是計算幾何加並查集嘛。當然,並查集部分很簡單,主要就是計算幾何了,打了兩個小時,我了個去,計算幾何功底還是不行啊。。。

/*

* hdu1558/win.cpp

* created on: 2012-8-16

* author : ben */

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

using

namespace

std;

const

int maxn = 1005

;#define zero(x) (((x)>0?(x):-(x))const

double eps = 1e-8

;typedef

double

typec;

typedef

struct

mypoint mypoint;

typedef

struct

myline myline;

inline

double

xmult(mypoint p1, mypoint p2, mypoint p0)

intdots_inline(mypoint p1, mypoint p2, mypoint p3)

inline

intsame_side(mypoint p1, mypoint p2, myline l)

inline typec xmult(typec x1, typec y1, typec x2, typec y2, typec x0, typec y0)

inline

intdot_online_in(typec x, typec y, typec x1, typec y1, typec x2,

typec y2)

if (!zero(xmult(x,y,x1,y1,x2,y2)))

if ((x1 - x) * (x2 - x) < eps && (y1 - y) * (y2 - y) return1;

}inline

int dot_online_in(const mypoint &p, const myline &l)

//包括端點和部分重合

bool

intersect_in(myline u, myline v)

intmyset[maxn], n;

myline lines[maxn];

void

initset()

}inline

int myfind(int

x) void mymerge(int a, int

b)

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

}}int

main()

}n++;

}else

if(c == 'q'

) }

printf(

"%d\n

", ans);}}

if(t > 0

) }

return0;

}

hdu1558並查集 線段相交

hdu1558 關於線段相交的內容參考演算法導論p577 include include includeusing namespace std int pre 1010 sum 1010 struct point struct edge edge 1010 int e 邊數 int find int...

hdu 1558 線段相交判斷 並查集

2535437 2010 06 12 00 42 04 accepted 1558 109ms 256k 2695 b c t t include include include using namespace std struct point struct sdlxd 1002 int p 100...

hdu1558 並查集 判斷線段相交

簡單的計算幾何題,判斷兩線段是否相交。將相交的兩線段使用並查集歸到一類中。查詢時輸出線段對應集合中元素的個數。includestruct point struct segmentnode 1010 int n,parent 1010 int getabs int value int getparen...