最大生成树

# include 
# define pp make_pair
using namespace std;
typedef long long LL;
const int maxn = 1e6+30;
const int N = 260000;
const LL mod = 1e9+7;
const int inf = 0x3f3f3f3f;
vectorg[N];
struct node{
    int u, v, w;
}edge[maxn];
bool cmp(node i, node j){
    return i.w > j.w;
}
int fa[N];
int Find(int x){
return x==fa[x]?x:fa[x]=Find(fa[x]);}
int f[N][23], h[N];
void dfs(int cur, int pre){
    f[cur][0] = pre;
    for(int i=1; i<=20; ++i){
        f[cur][i] = f[f[cur][i-1]][i-1];
    }
    for(int i=0; i h[u]) swap(v, u);
    for(int i=0; i<=20; ++i)
        if(h[u]-h[v]>>i & 1)
        u=f[u][i];
    for(int i=20; i>=0; --i)
        if(f[v][i] != f[u][i])
         v=f[v][i], u=f[u][i];
    return v==u?v:f[v][0];
}
int main(){
    int n, m;
    char a, c;
    int b, d, cnt=0;
    scanf("%d%d",&n,&m);
    for(int i=0; i

 

你可能感兴趣的:(ACM笔记-3图流)