对所有边从大到小排序,枚举最大边,O(m)验证,用并查集维护图是否联通. program CODEVS1001; ; maxn=; INF=; type arr=record u,v,w:int64; end; ..maxm] of arr; fa:..maxn] of longint; i,j,m,n,x,y,z,s,t,u,v,d:longint; ans1,ans2:int64; procedure add(u,v,w:longint); begin inc(j); eg[j].u:=u;…