jungle

POJ 1251-Jungle Roads(最小生成树)

ぃ、小莉子 提交于 2020-03-08 12:14:27
Jungle Roads Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 38773 Accepted: 18244 Description The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentlessly, so the large road network is too expensive to maintain. The Council of Elders must choose to stop maintaining some roads. The map above on the left shows all the roads in use now and the cost in aacms per month to maintain them. Of course there needs to be some way to get between all the

A - Jungle Roads

匿名 (未验证) 提交于 2019-12-03 00:29:01
Input Output Sample Input 9 A 2 B 12 I 25 B 3 C 10 H 40 I 8 C 2 D 18 G 55 D 1 E 44 E 2 F 60 G 38 F 0 G 1 H 35 H 1 I 35 3 A 2 B 10 C 40 B 1 C 20 0 Sample Output 216 30 AC代码: # include <stdio.h> # include <iostream> # include <stdlib.h> # include <algorithm> # include <cstring> # include <queue> # define MAX 1<<22; using namespace std ; int z[ 1111 ][ 1111 ],p[ 1111 ],vis[ 1111 ],d[ 1111 ]; int a,b,c,pp,tt,closet[ 1111 ]; int m,n; void dks () { for ( int i= 1 ;i<=a;i++) { d[i]=z[ 1 ][i]; } for ( int i= 2 ;i<=a;i++) { int v; int t=MAX; for ( int j= 1 ;j<=a;j++) { if (d[j]!= 0 &&d[j]<t) { t=d[j];