回分類題庫
d311: (1052cp2_assignment6) Oreon
出處:UVA

Difficulity : 3
Accepted : 48 Times | Submit :190 Times | Clicks : 638
Accepted : 42 Users | Submit : 43 Users | Accepted rate : 98%
Time Limit :10000 ms | Memory Limit : 64000 KBytes
題目加入時間 : 2017-06-15 13:21

Content :

 In the 25th century, civilization is struck by a series of calamities that eventually led mankind to build walled cities interconnected by tunnel bridges to facilitate transportation. Each walled city possesses a unique ore required to build and repair all infrastructure including the tunnels. This material which when combined with other ores from all others cities form an almost indestructible material called “oreon”.

 Outside the walled cities are uncivilized barbarians armed with antiquated but destructive weaponry which can effectively shoot down any air transport, but only damage and not penetrate tunnel bridges. Thus each city is interconnected to more than one city in order to have access redundancy in case one of its interconnecting tunnels is damaged.

 If a tunnel is damaged, it becomes impassable and would require a substantial amount of “oreon” to repair the damage. When a single city is made isolated, meaning all of its interconnections are damaged, “oreon” cannot be manufactured which may lead to the eventual destruction of the wall fortifying the city. You, being the head of the homeland defense unit, are tasked to ensure that all cities remain accessible even by at least a single interconnecting tunnel at all times. Faced with only a limited manpower in the defense unit, you have to determine which tunnel to protect using the least number of people and ensure that no city will be isolated.

 Figure 2 shows a map of the walled cities, their interconnecting tunnels and the number of security personnel. 

 

Input :

 The input will contain several test cases. The first line will indicate the number of test cases. Each test case begins with a number representing the number of walled cities. Cities are labeled alphabetically using the letters in the English alphabet. The subsequent lines contain the number of security personnel needed to protect the tunnel connecting each city to all other cities. A value of zero implies no security personnel needed since no tunnel exists. You are to output how many personnel are needed.

Output :

 The output shows the minimum number of personel needed to protect the tunnel.

Sample Input :

2
6
0, 8, 12, 0, 0, 7
8, 0, 0, 3, 0, 0
12, 0, 0, 0, 6, 0
0, 3, 0, 0, 0, 4
0, 0, 6, 0, 0, 5
7, 0, 0, 4, 5, 0
6
0, 8, 12, 0, 0, 7
8, 0, 0, 3, 0, 0
12, 0, 0, 0, 6, 0
0, 3, 0, 0, 0, 4
0, 0, 6, 0, 0, 5
7, 0, 0, 4, 5, 0

Sample Output :

25
25

Hint :


  

Author :

UVA (管理員:cp2ta)

  Solve it!   Status Forum (0)

C++
C
JAVA
86446. nccucs105703036 (7 ms , 270KB)
86350. nccucs104703048 (7 ms , 236KB)
86436. nccucs104703009 (8 ms , 233KB)
86419. s10536 (8 ms , 274KB)
86408. nccucs105703030 (8 ms , 276KB)
86413. nccucs105703012 (4 ms , 268KB)
86380. nccucs105703004 (6 ms , 232KB)
86355. nccucs103702024 (6 ms , 273KB)
86354. nccucs103702024 (6 ms , 282KB)
85765. nccucs105703001 (6 ms , 236KB)
沒有解題記錄

執行時間會受很多因素影響因此僅供參考,主機等級請看這裡