摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4690 【题解】 带权并查集 fa[x]表示x的父亲,a[x]表示x到x的父亲多/少多少 那么找祖先的时候算一下到祖先多少,然后路径压缩。 合并的时候注意让fa[fx]=fy的时候,a[fx]是 阅读全文
posted @ 2017-05-26 21:44 Galaxies 阅读(149) 评论(0) 推荐(0)
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4759 【题解】 排序,从大到小插入,树状数组统计。 # include <vector> # include <stdio.h> # include <string.h> # include 阅读全文
posted @ 2017-05-26 20:16 Galaxies 阅读(220) 评论(0) 推荐(0)
摘要: 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4756 【题解】 dsu on tree,树状数组直接上 O(nlog^2n) # include <vector> # include <stdio.h> # include <string. 阅读全文
posted @ 2017-05-26 16:17 Galaxies 阅读(244) 评论(0) 推荐(0)