作者:我所信仰的感觉 | 来源:互联网 | 2023-05-17 16:35
此题关键要理解输出的定义
For each test case, you should output a line contains an integer, which is the length of the longest road to be built such that all the villages are connected, and this value is minimum.
输出是最小生成树中最长边的长度
对prim算法稍作变化即可AC
Source Code
Problem: 2485 |
|
User: yangliuACMer |
Memory: 1232K |
|
Time: 750MS |
Language: C++ |
|
Result: Accepted |
#include
#define MAXN 500
#define inf 65537
typedef int elem_t;
using namespace std;
elem_t prim(int n,elem_t mat[MAXN][MAXN],int* pre){
elem_t min[MAXN],ret=0,maxLen=-1;
int v[MAXN],i,j,k;
for (i=0;i>m;
while(m--){
cin>>n;
for (i = 0;i >distance[i][j];
}
result = prim(n,distance,pre);
cout<