题目:
分析:
很明显,查询的是删掉某条边后两端点所在连通块大小的乘积。
有加边和删边,想到LCT。但是我不会用LCT查连通块大小啊。果断弃了
有加边和删边,还跟连通性有关,于是开始yy线段树分治做法(不知道线段树分治?推荐一个伪模板题事实上这个链接是指向我的博客的)。把每次操作(加边或查询)看做一个时刻,一条边存在的区间就是它加入后没有被查询的时间区间的并。于是用可撤销并查集维护一下连通块大小即可。
代码:
#include #include #include #include #include