随笔分类 - *数据结构---并查集
摘要:Building Block HDU - 2818 题意:搬砖。。。每一次可以把a所在的那一堆放到b所在的那一堆上面,问第x号砖下面有几块砖。 记录一下到根节点的距离(dw),以及根节点上方有几块砖(up)。 1 #include <bits/stdc++.h> 2 using namespace
阅读全文
摘要:Farm Irrigation HDU - 1198 题意:给11种管道,问草地最少需要打多少个井才可以全部灌溉。 把每种管道的状态用二进制表示一下,然后对每一块草地,判断能否和上面或者左面的草地的管道连接。 然后并查集搞一下。 1 #include <bits/stdc++.h> 2 using
阅读全文
摘要:Exclusive-OR UVALive - 4487 带权并查集,回去再写 Exclusive-OR UVALive - 4487 Exclusive-OR 带权并查集,回去再写 1 #include <bits/stdc++.h> 2 using namespace std; 3 #define
阅读全文
摘要:Dragon Balls HDU - 3635 题意:转移小球. 并查集. 1 #include<cstdio> 2 #include<cstring> 3 const int maxn=10010; 4 int f[maxn],ct[maxn],trans[maxn]; 5 int n,m; 6
阅读全文
摘要:More is better HDU - 1856 题意:给出n个关系,问最多有多少个人直接或者间接有关系. 并查集. 1 #include <bits/stdc++.h> 2 using namespace std; 3 4 const int maxn=10000010; 5 int f[max
阅读全文
摘要:题目链接:http://poj.org/problem?id=2492 参考食物链。http://www.cnblogs.com/yijiull/p/6527465.html
阅读全文
摘要:题目链接:http://poj.org/problem?id=2912 和食物链那题差不多,稍微复杂一点。 枚举裁判,然后其他人判断是否冲突。
阅读全文
摘要:题目链接:http://poj.org/problem?id=1182 搞了好久才弄明白。。。之前学并查集从来没想过能这么用,并查集+向量偏移!!! 与一般并查集只开一个father数组不同,还要开一个ralation数组用来记录子节点与父节点的关系,对于此题,显然每个点对应根节点可能有三种关系,我
阅读全文

浙公网安备 33010602011771号