行业知识
[蓝桥杯 2017 国 C] 合根植物(P8654)
2026-11-26 18:30:43
来源:互联网转载
#include #define endl '\n'using ll = long long;typedef unsigned long long ull;using namespace std;void GordenGhost();int n,m;mapfa;int findB(int x){ if (fa[x]==x)return x; return fa[x]=findB(fa[x]);}void unionSet(int x,int y){ fa[findB(x)]= findB(y);}signed main() {#ifdef Gorden freopen("in.txt", "rt", stdin); freopen("out.txt", "wt", stdout);#endif ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); GordenGhost(); return 0;}void GordenGhost() { cin>>n>>m; for (int i = 1; i >t; while(t--){ int a,b; cin>>a>>b; unionSet(a,b); } int sum=0; mapmp; for (int i = 1; i