首页 > TAG信息列表 > HDU3047

HDU3047-Zjnu Stadium(加权并查集)

先说一下加权并查集: 每个节点都记录的是与自己的根节点之间的权值, 那么在Find的路径压缩过程中,权值也应该做相应的更新,因为在路径压缩之前,每个节点都是与其父节点链接着,每个节点的Value自然也是与其父节点之间的权值。 2.在两个并查集做合并的时候,权值也要做相应的更新,因为两个并

HDU3047 Zjnu Stadium (带权并查集)

经典的向量法,只要找出数学关系就行了 #include<iostream> #include<algorithm> #include<string> #include<cstring> #include<vector> #include<cstdio> #include<map> using namespace std; const int N=1e5+10; int n,m; int p[N]; int d[N];

HDU3047-Zjnu Stadium-带权并查集

In 12th Zhejiang College Students Games 2007, there was a new stadium built in Zhejiang Normal University. It was a modern stadium which could hold thousands of people. The audience Seats made a circle. The total number of columns were 300 numbered 1--300