QS Network

Sunny Cup 2003 - Preliminary Round

April 20th, 12:00 - 17:00

Problem E: QS Network


In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS. QScommunicate with each other via networks. If two QS want to get connected, they need to buy two network adapters (one for each QS) and a segment of network cable. Please be advised that ONE NETWORK ADAPTER CAN ONLY BE USED IN A SINGLE CONNECTION.(ie. if a QS want to setup four connections, it needs to buy four adapters). In the procedure of communication, a QS broadcasts its message to all the QS it is connected with, the group of QS who receive the message broadcast the message to all the QS they connected with, the procedure repeats until all the QS's have received the message.

A sample is shown below:


A sample QS network, and QS A want to send a message.

Step 1. QS A sends message to QS B and QS C;

Step 2. QS B sends message to QS A ; QS C sends message to QS A and QS D;

Step 3. the procedure terminates because all the QS received the message.

Each QS has its favorate brand of network adapters and always buys the brand in all of its connections. Also the distance between QS vary. Given the price of each QS's favorate brand of network adapters and the price of cable between each pair of QS, your task is to write a program to determine the minimum cost to setup a QS network.


Input

The 1st line of the input contains an integer t which indicates the number of data sets.

From the second line there are t data sets.

In a single data set,the 1st line contains an interger n which indicates the number of QS.

The 2nd line contains n integers, indicating the price of each QS's favorate network adapter.

In the 3rd line to the n+2th line contain a matrix indicating the price of cable between ecah pair of QS.

Constrains:

all the integers in the input are non-negative and not more than 1000.


Output

for each data set,output the minimum cost in a line. NO extra empty lines needed.


Sample Input

1
3
10 20 30
0 100 200
100 0 300
200 300 0


Sample Output

370







### 关于ENSP QS测试的配置方法 ENSP(Enterprise Network Simulation Platform)是一款由华为推出的网络仿真平台,主要用于帮助用户学习和实践企业级网络技术。在ENSP中进行QS测试通常涉及配置特定的设备接口、启用相应的协议以及设置认证模式等内容。 以下是关于ENSP QS测试的相关说明: #### 1. 设备初始化与基本配置 在ENSP中创建并启动所需的路由器或交换机设备后,需完成基础配置以确保设备能够正常运行。这包括但不限于分配IP地址给各个接口[^4]: ```python sysname R1 interface GigabitEthernet0/0/0 ip address 192.168.1.1 255.255.255.0 quit ``` #### 2. 启用动态路由协议OSPF 为了实现不同子网之间的通信,在ENSP中可以配置OSPF作为动态路由协议。通过指定区域号和网络范围来定义OSPF的工作环境[^2]: ```python ospf 1 router-id 1.1.1.1 area 0.0.0.0 network 192.168.1.0 0.0.0.255 quit ``` #### 3. 设置链路认证机制 为增强网络安全性和可靠性,可以在相邻节点间实施简单的明文密码或者更安全的MD5哈希算法来进行身份验证[^2]: ```python interface GigabitEthernet0/0/1 ospf authentication-mode simple plain goktech quit ``` 对于更高安全性需求,则采用如下命令替代简单文本形式: ```python interface GigabitEthernet0/0/0 ospf authentication-mode md5 1 cipher goktech quit ``` #### 4. IPv6支持及相关服务开启 随着互联网规模不断扩大,IPv4资源逐渐枯竭,因此引入下一代协议即IPv6变得尤为重要。下面展示如何在一个千兆位以太网上激活该版本的服务,并同时部署对应的开放短路径优先第三版(OSPFv3)[^3]: ```python interface GigabitEthernet0/0/0 ipv6 enable ipv6 address 2001::FFFF/64 undo ipv6 nd ra halt ospfv3 1 area 0.0.0.0 quit ``` #### 5. 用户界面定制化调整 后一步是对Console端口做进一步精细化管理,比如修改波特率参数、奇偶校验选项以及其他高级特性等[^5], 这样有助于提高远程维护效率同时也加强了系统的整体防护能力. ```python user-interface con 0 speed 9600 parity none stop-bit 1 idle-timeout 30 0 screen-length 25 history-command max-size 10 authentication-mode password set authentication password cipher $1c$goktech$ quit ``` 以上就是在ENSP平台上执行QS测试的主要流程概述及其对应的关键指令片段集合. ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值