HDU 1233(最小生成树 模板) #include <iostream> #include <algorithm> #include <cstdio> using namespace std; typedef struct { int a,b; int v; }node; const int maxn=105; int ans; int father[maxn]; node graph[maxn*(maxn-1)/2]; int Find(int x) { if(f…
poj 1251 && hdu 1301 Sample Input 9 //n 结点数A 2 B 12 I 25B 3 C 10 H 40 I 8C 2 D 18 G 55D 1 E 44E 2 F 60 G 38F 0G 1 H 35H 1 I 353A 2 B 10 C 40B 1 C 200Sample Output 21630 prim算法 # include <iostream> # include <cstdio> # include <cstr…
Qin Shi Huang's National Road System Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6137 Accepted Submission(s): 2143 Problem Description During the Warring States Period of ancient China(47…
Description The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are to be used in establishing the network: every outpost will have a radio transceiver a…
题意:求最小生成树,和任意两个点之间距离的期望 官方题解: 最后求两遍点的积的时候,还是要判断父子关系. 注意 long long #include <bits/stdc++.h> using namespace std; typedef long long LL; +; int father[maxn]; int Find_Set(int x) { if(x!=father[x]) father[x] = Find_Set(father[x]); return father[x]; } st…