随笔分类 -  图论 —— 并查集

Codeforces - 828C String Reconstruction —— 并查集find()函数
摘要:题目链接:http://codeforces.com/contest/828/problem/C C. String Reconstruction time limit per test 2 seconds memory limit per test 256 megabytes input stan 阅读全文

posted @ 2018-04-22 21:20 h_z_cong 阅读(181) 评论(0) 推荐(0)

51Nod 1515 明辨是非 —— 并查集 + 启发式合并
摘要:题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1515 1515 明辨是非 题目来源: 原创 基准时间限制:1 秒 空间限制:131072 KB 分值: 160 难度:6级算法题 收藏 关注 1515 明辨是非 阅读全文

posted @ 2018-04-06 14:43 h_z_cong 阅读(262) 评论(0) 推荐(0)

并查集 专题总结
摘要:一.题目类型: 1.普通并查集: poj2513 Colored Sticks hdu1198 Farm Irrigation SCAU 1138 代码等式 Gym - 100676F Palindrome Codeforces Round #363 (Div. 2) D. Fix a Tree C 阅读全文

posted @ 2017-11-04 15:24 h_z_cong 阅读(162) 评论(0) 推荐(0)

POJ1417 True Liars —— 并查集 + DP
摘要:题目链接:http://poj.org/problem?id=1417 True Liars Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3851 Accepted: 1261 Description After having 阅读全文

posted @ 2017-10-15 14:20 h_z_cong 阅读(238) 评论(0) 推荐(0)

ZOJ3261 Connections in Galaxy War —— 反向并查集
摘要:题目链接:https://vjudge.net/problem/ZOJ-3261 In order to strengthen the defense ability, many stars in galaxy allied together and built many bidirectional 阅读全文

posted @ 2017-10-14 14:34 h_z_cong 阅读(432) 评论(0) 推荐(0)

POJ1733 Parity game —— 种类并查集
摘要:题目链接:http://poj.org/problem?id=1733 Parity game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 3795 Description Now and the 阅读全文

posted @ 2017-10-13 16:02 h_z_cong 阅读(266) 评论(0) 推荐(0)

POJ1984 Navigation Nightmare —— 种类并查集
摘要:题目链接:http://poj.org/problem?id=1984 Navigation Nightmare Time Limit: 2000MS Memory Limit: 30000K Total Submissions: 7136 Accepted: 2556 Case Time Limi 阅读全文

posted @ 2017-10-13 16:00 h_z_cong 阅读(233) 评论(0) 推荐(0)

POJ2912 Rochambeau —— 种类并查集 + 枚举
摘要:题目链接:http://poj.org/problem?id=2912 Rochambeau Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 3663 Accepted: 1285 Description N children a 阅读全文

posted @ 2017-10-13 15:59 h_z_cong 阅读(405) 评论(0) 推荐(1)

POJ1456 Supermarket —— 贪心 + 路径压缩优化
摘要:题目链接:http://poj.org/problem?id=1456 Supermarket Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13736 Accepted: 6206 Description A supermar 阅读全文

posted @ 2017-10-11 21:12 h_z_cong 阅读(432) 评论(0) 推荐(0)

POJ2492 A Bug's Life —— 种类并查集
摘要:题目链接:http://poj.org/problem?id=2492 A Bug's Life Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 39415 Accepted: 12835 Description Backgro 阅读全文

posted @ 2017-10-11 20:34 h_z_cong 阅读(260) 评论(0) 推荐(0)

POJ1182 食物链 —— 种类并查集
摘要:题目链接:http://poj.org/problem?id=1182 食物链 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 78133 Accepted: 23275 Description 动物王国中有三类动物A,B,C,这 阅读全文

posted @ 2017-10-11 19:24 h_z_cong 阅读(204) 评论(0) 推荐(0)

HDU3038 How Many Answers Are Wrong —— 带权并查集
摘要:题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=3038 How Many Answers Are Wrong Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 阅读全文

posted @ 2017-10-11 19:20 h_z_cong 阅读(251) 评论(0) 推荐(0)

Codeforces Round #376 (Div. 2) C. Socks —— 并查集 + 贪心
摘要:题目链接:http://codeforces.com/contest/731/problem/C 题解: 1.看题目时,大概知道,不同的袜子会因为要在同一天穿而差生了关联(或者叫相互制约), 其中一条袜子可以穿多次或者不穿。那么自然就想到用并查集(DSU), 把有关联的袜子放在一个集合(经过处理后, 阅读全文

posted @ 2017-05-31 15:37 h_z_cong 阅读(222) 评论(0) 推荐(0)

Codeforces Round #363 (Div. 2) D. Fix a Tree —— 并查集
摘要:题目链接:http://codeforces.com/contest/699/problem/D D. Fix a Tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input 阅读全文

posted @ 2017-05-13 15:22 h_z_cong 阅读(232) 评论(0) 推荐(0)

Gym - 100676F Palindrome —— 并查集
摘要:题目链接:https://vjudge.net/contest/155789#problem/E 题解: 由于是回文串,所以可以先将在对称位置的字符放在同一个集合(如果期间有两个非‘?’,且不相等,则退出操作。并跳过之后的某些步骤。注意输入不能跳过)。然后再接收输入的限制条件,进行并查集。有两种并查 阅读全文

posted @ 2017-03-30 15:17 h_z_cong 阅读(252) 评论(0) 推荐(0)

SCAU 1138 代码等式 并查集
摘要:1138 代码等式[附加题] 该题有题解 时间限制:500MS 内存限制:65536K 提交次数:59 通过次数:21 题型: 编程题 语言: G++;GCC Description 输入格式 第一行数N为变量个数; 第二行N个数,为每个变量的位数 第三行为一个等式 输入格式 输出格式 输出解的个数 阅读全文

posted @ 2017-03-10 16:18 h_z_cong 阅读(439) 评论(0) 推荐(0)

hdu1198 Farm Irrigation —— dfs or 并查集
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1198 dfs: 1 #include<cstdio>//hdu1198 dfs 2 #include<cstring> 3 4 int well[11][5] = { {1,1,1,0,0},{1,0, 阅读全文

posted @ 2017-03-03 19:59 h_z_cong 阅读(237) 评论(0) 推荐(0)

poj2513 Colored Sticks —— 字典树 + 并查集 + 欧拉回路
摘要:题目链接:http://poj.org/problem?id=2513 题解:通过这题了解了字典树。用字典树存储颜色,并给颜色编上序号。这题为典型的欧拉回路问题:将每种颜色当成一个点。首先通过并查集判断是否为连通图,再检验是否符合欧拉回路的特点。不过题目有一点很奇怪,在并查集中,若图为连通,不是有且 阅读全文

posted @ 2017-02-23 21:25 h_z_cong 阅读(247) 评论(0) 推荐(0)

导航