并查集
Zackory
这个作者很懒,什么都没留下…
展开
-
hdu 3038
题目链接 关于并查集系列问题的解法链接 #include<iostream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; const int maxn=200010; int pre[maxn]; int sum[maxn]; int find...原创 2018-07-23 20:26:16 · 261 阅读 · 0 评论 -
poj E
题目链接 #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int maxn=200000; int pre[maxn]; int enemy[maxn]; int find(int x) { return pre[x]==x?x:fi...原创 2018-07-18 19:43:26 · 115 阅读 · 0 评论 -
poj C
题目链接 #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int maxn=50005; int pre[maxn],vis[maxn]; int find(int x) { int r=x; while(r!=pre[r])...原创 2018-07-18 19:45:39 · 362 阅读 · 0 评论 -
poj B
题目链接 #include<iostream> #include<cstdio> #include<cstring> #include<vector> #include<cmath> using namespace std; const int maxn=1010; struct node { int x,y; }N[max...原创 2018-07-18 19:47:22 · 237 阅读 · 0 评论 -
poj A
题目链接 #include<iostream> #include<cstring> #include<cstdio> using namespace std; const int maxn=10000; int p[maxn]; int vis[maxn]; int R[maxn]; void init() { for(int i=0; i<=...原创 2018-07-18 19:49:04 · 219 阅读 · 0 评论 -
A Bug's Life
A Bug’s Life 此题的题意是分别给出多组数据,每组数据是不同的性别,让你分析是否给出的数据中存在相同的性别,输出指定的语句。 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int pre[2009]; int enemy[2009]; ...原创 2018-07-25 14:32:27 · 835 阅读 · 0 评论