编程介的小学生 2017-05-13 09:49 采纳率: 0.2%
浏览 717
已采纳

Oreon

Description

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.

Figure 2: Map of six cities and its interconnecting tunnels
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, thus limiting their quantity. 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 which tunnel should be protected and how many personnel are needed for each tunnel.

Output

The output shows the tunnel connection which is named after the cities that it connects (in alphabetical order) and the number of personel needed to protect the tunnel. Order the records in increasing order of presonal. In case two tunnels have the same number of personel, write them in lexicographycal order.

Sample Input

1
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

Case 1:
B-D 3
D-F 4
E-F 5
C-E 6
A-F 7
Hint

For each test case, if more than one solutions are possible. Output the least one (the whole section of output for the test case) in lexicographycal order. See the sample below

Hint Input
1
3
0, 1, 1
1, 0, 1
1, 1, 0
Hint Output
Case 1:
A-B 1
A-C 1

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-05-30 15:55
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 需要跳转番茄畅听app的adb命令
  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证