摘要:
#include<bits/stdc++.h> using namespace std; const int N=1e4+10; int n,p,k,m; int T; int a[N]; int main() { cin>>T; while(T--) { cin>>n>>k>>p>>m; for( 阅读全文
摘要:
https://www.luogu.com.cn/problem/P2168#ide #include<cstdio> #include<cstring> #include<queue> #include<algorithm> #define ll long long using namespace 阅读全文
摘要:
我们用并查集求最大值,然后看有多少个没有闭环的并查集(有邻居数<=2的就是未闭环),设未闭环的总共有num个。若num>0,那么答案就是cnt-num+1个。注意每一次要状态恢复 #include<bits/stdc++.h> using namespace std; const int N=2e5 阅读全文
摘要:
这道题教会了我并查集是可以动态删改的,关键在于判断其是否是连通分量的代表 #include<bits/stdc++.h> using namespace std; typedef long long LL; LL t,n,m1,m2,ans,a[500005],b[500005],fag[50000 阅读全文