
并查集
文章平均质量分 79
DOLFAMINGO
诗酒趁年华
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
poj2513 Colored Sticks —— trie树 + 并查集 + 欧拉回路
题目链接:http://poj.org/problem?id=2513 题解:…… 代码如下: #include #include #include #define MAXN 500010 typedef struct node { struct node *next[26]; int pos; }Trie, *PT; int n,fa[MAXN]原创 2017-02-23 21:24:45 · 442 阅读 · 0 评论 -
hdu1198 Farm Irrigation —— dfs or 并查集
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1198 dfs: #include//hdu1198 dfs #include int well[11][5] = { {1,1,1,0,0},{1,0,1,1,0},{0,1,1,0,1},{0,0,1,1,1},{1,0,1,0,1},{0,1,1,1,0},{1,1,1,1,0},{原创 2017-03-03 19:59:05 · 337 阅读 · 0 评论 -
SCAU 1138 代码等式 并查集
1138 代码等式[附加题] 该题有题解 时间限制:500MS 内存限制:65536K 提交次数:59 通过次数:21 题型: 编程题 语言: G++;GCC Description 一个代码等式就是形如x1x2...xi=y1y2...yj,这里xi和yj是二进制的数字(0或1)或者是一个变量(如英语中的小写字母)。 每一个变量都是一个有固定原创 2017-03-10 16:18:09 · 592 阅读 · 0 评论 -
Gym - 100676F Palindrome —— 并查集
题目链接:https://vjudge.net/contest/155789#problem/E 题解: 由于是回文串,所以可以先将在对称位置的字符放在同一个集合(如果期间有两个非‘?’,且不相等,则退出操作。并跳过之后的某些步骤。注意输入不能跳过)。然后再接收输入的限制条件,进行并查集。有两种并查集的方式,而两种方式的共同点都是根节点存放这个集合的字符值。 :方法一(根据字原创 2017-03-30 15:16:55 · 504 阅读 · 0 评论 -
POJ2524 Ubiquitous Religions —— 并查集
题目链接:http://poj.org/problem?id=2524 题解: 找出最多能有多少个不同的宗教,直接并查集就可以了。 第一次提交时没有注意到要输出“Case %d :”, 以后要注意了,细心读题。 代码如下: #include//B - Ubiquitous Religions POJ - 2524 纯并查集 #include #include #inc原创 2017-03-24 15:25:14 · 413 阅读 · 0 评论 -
Codeforces Round #376 (Div. 2) C. Socks —— 并查集 + 贪心
题目链接:http://codeforces.com/contest/731/problem/C C. Socks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output原创 2017-05-31 15:36:50 · 329 阅读 · 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 output standard o原创 2017-05-13 15:22:21 · 286 阅读 · 0 评论