一道裸的并查集,练练手不错. program CODEVS1073; var i,j,m,n,q,x,y,k1,k2,z:longint; f:..] of longint; function find(x:longint):longint; var fa:longint; begin while f[x]=x do exit(x); fa:=find(f[x]); f[x]:=fa; exit(fa); end; begin readln(n,m,q); to n do f[i]:=i; to…
题目如下: One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be the total time length of all the phone calls…
dfs #include<bits/stdc++.h> using namespace std; ; int mp[N][N]; int weight[N]; int vis[N]; map<string,int>si; map<int,string>is; map<string,int>gang; int cnt;//进行转换 int solve(string x) { if(si.find(x)!=si.end()){ return si[x]; } e…