![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
并查集
天心流月
这个作者很懒,什么都没留下…
展开
-
[Codeforces]1263D Secret Passwords
题目 One unknown hacker wants to get the admin’s password of AtForces testing system, to get problems from the next contest. To achieve that, he sneaked into the administrator’s office and stole a piece...原创 2019-12-04 17:16:39 · 241 阅读 · 0 评论 -
[洛谷Luogu]P1141 01迷宫[联通块 并查集]
题目链接 大致题意 相邻格子不同为连通,计算每个点所在的连通块大小。 想法 我采用了并查集的做法。 开一个辅助数组记录连通块大小,每次合并的时候更新父亲节点的大小即可。 一个点先与它上面的点判定,若判定连通则加入上方点所属的块中。 再与左边的点判定,若连通则再将两个块合并。 总体复杂度O(n3)O(n^3)O(n3),其中并查集不加优化复杂度为O(n)O(n)O(n),使用路径压缩+按节点大小...原创 2019-11-28 17:35:48 · 218 阅读 · 0 评论