随笔分类 -  并查集

摘要:题目来源 399. 除法求值 题目详情 给你一个变量对数组 equations 和一个实数值数组 values 作为已知条件,其中 equations[i] = [Ai, Bi] 和 values[i] 共同表示等式 Ai / Bi = values[i] 。每个 Ai 或 Bi 是一个表示单个变量 阅读全文
posted @ 2021-12-28 11:00 Garrett_Wale 阅读(112) 评论(0) 推荐(0) 编辑
摘要:合根植物 "PREV 54" 这题主要考察的也是并查集。 直接应用并查集的模板就可以了。 阅读全文
posted @ 2020-03-13 11:12 Garrett_Wale 阅读(172) 评论(0) 推荐(0) 编辑
摘要:食物链 "POJ 1182" 一个很好的分析博客:https://blog.csdn.net/niushuai666/article/details/6981689 三种关系:两者同类,吃父节点,被父节点吃,所以权值可以用0,1,2表示 include include include include 阅读全文
posted @ 2019-08-25 08:58 Garrett_Wale 阅读(107) 评论(0) 推荐(0) 编辑
摘要:How many answers wrong "HDOJ 3038" 一个很好的博客:https://www.cnblogs.com/liyinggang/p/5327055.html include include include include include include using nam 阅读全文
posted @ 2019-08-24 21:13 Garrett_Wale 阅读(96) 评论(0) 推荐(0) 编辑
摘要:How many tables "HDOJ 1213" include include include include include include include include using namespace std; const int maxn=1004; int n,m; int set 阅读全文
posted @ 2019-08-24 20:10 Garrett_Wale 阅读(106) 评论(0) 推荐(0) 编辑
摘要:The Suspects "POJ 1611" 这题就是并查集的简单应用 include include include include include include include include using namespace std; const int maxn=30004; int n, 阅读全文
posted @ 2019-08-24 20:03 Garrett_Wale 阅读(180) 评论(0) 推荐(0) 编辑
摘要:Wireless NetWork "POJ 2236" 需要注意这里的树的深度需要初始化为0。 而且,find函数需要使用路径压缩,这里的unint合并函数也使用了优化(用一开始简单的合并过不了)。 include include include include include include us 阅读全文
posted @ 2019-08-24 19:37 Garrett_Wale 阅读(113) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示