
并查集
文章平均质量分 71
Roly_Yu
快码佳编
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
poj(1988)
题目:http://poj.org/problem?id=1988 带权并查集的题目。 // father[x] 为x的父亲节点(x所在stack顶端的cube) // weight[x] 为x所在stack包含的cube数量 // up[x] 为在x上方的cube的数量 // 则x之下的cube数应为weight[find(x)]-up[x]-1 // 即用x的父亲节点所在stack的cube数原创 2014-03-13 14:16:26 · 587 阅读 · 0 评论 -
hdu(4514)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4514 这道题是一个带权并查集的题目。 #include #include #include using namespace std; const int maxn = 100005; int father[maxn]; int rank[maxn]; int weight[maxn原创 2014-03-13 14:16:24 · 666 阅读 · 0 评论 -
hdu(1272)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1272 一道并查集的基础题目。 注意两点 1.合并时判断是否同一集合 2.合并之后是否连通 #include #include #include using namespace std; const int maxn = 100005; int father[maxn]; int rank[maxn原创 2014-03-13 14:16:19 · 700 阅读 · 0 评论 -
hdu(1213)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1213 #include #include #include using namespace std; const int maxn = 1005; int father[maxn]; int rank[maxn]; void make_set(int x){//初始化 father[x] =原创 2014-03-13 14:16:17 · 539 阅读 · 0 评论 -
九度OJ 题目1526:朋友圈(小米2013年校园招聘笔试题)
#include #include #include #include using namespace std; const int maxn = 100005; int father[maxn]; int rank[maxn]; int flag[maxn]; int n,m; void make_set(int n){ for(int i = 1;i <= n;i++){原创 2014-11-01 11:09:24 · 726 阅读 · 0 评论