摘要: 我们用并查集求最大值,然后看有多少个没有闭环的并查集(有邻居数<=2的就是未闭环),设未闭环的总共有num个。若num>0,那么答案就是cnt-num+1个。注意每一次要状态恢复 #include<bits/stdc++.h> using namespace std; const int N=2e5 阅读全文
posted @ 2026-02-19 20:57 曾翎一 阅读(11) 评论(0) 推荐(0)