{"trustable":true,"prependHtml":"\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003ch2 align\u003d\"center\"\u003eSunny Cup 2003 - Preliminary Round\u003c/h2\u003e\n\u003cp align\u003d\"center\"\u003eApril 20th, 12:00 - 17:00 \u003c/p\u003e\n\u003ch3 align\u003d\"center\"\u003eProblem E: QS Network\u003c/h3\u003e\n\u003cp\u003e\u003cbr\u003e\n In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named \n QS. QScommunicate with each other via networks. If two QS want to get connected, \n they need to buy two network adapters (one for each QS) and a segment of network \n cable. Please be advised that ONE NETWORK ADAPTER CAN ONLY BE USED IN A SINGLE \n CONNECTION.(ie. if a QS want to setup four connections, it needs to buy four \n adapters). In the procedure of communication, a QS broadcasts its message to \n all the QS it is connected with, the group of QS who receive the message broadcast \n the message to all the QS they connected with, the procedure repeats until all \n the QS\u0027s have received the message.\u003c/p\u003e\n\u003cp\u003eA sample is shown below:\u003c/p\u003e\n\u003cp align\u003d\"center\"\u003e\u003cimg src\u003d\"CDN_BASE_URL/1120637f03c5c4bc9402775a6100caa8?v\u003d1714515477\" width\u003d\"232\" height\u003d\"197\"\u003e\u003c/p\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n A sample QS network, and QS A want to send a message.\u003cbr\u003e\n \u003cbr\u003e\n Step 1. QS A sends message to QS B and QS C;\u003cbr\u003e\n \u003cbr\u003e\n Step 2. QS B sends message to QS A ; QS C sends message to QS A and QS D;\u003cbr\u003e\n \u003cbr\u003e\n Step 3. the procedure terminates because all the QS received the message.\u003c/p\u003e\n\u003cp\u003e Each QS has its favorate brand of network adapters and always buys the brand \n in all of its connections. Also the distance between QS vary. Given the price \n of each QS\u0027s favorate brand of network adapters and the price of cable between \n each pair of QS, your task is to write a program to determine the minimum cost \n to setup a QS network.\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eInput\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003eThe 1st line of the input contains an integer t which indicates the number \n of data sets.\u003cbr\u003e\n \u003cbr\u003e\n From the second line there are t data sets.\u003cbr\u003e\n \u003cbr\u003e\n In a single data set,the 1st line contains an interger n which indicates the \n number of QS.\u003cbr\u003e\n \u003cbr\u003e\n The 2nd line contains n integers, indicating the price of each QS\u0027s favorate \n network adapter.\u003cbr\u003e\n \u003cbr\u003e\n In the 3rd line to the n+2th line contain a matrix indicating the price of cable \n between ecah pair of QS.\u003c/p\u003e\n\u003cp\u003eConstrains:\u003c/p\u003e\n\u003cp\u003eall the integers in the input are non-negative and not more than 1000.\u003c/p\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eOutput\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003efor each data set,output the minimum cost in a line. NO extra empty lines needed.\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eSample Input\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003e1\u003cbr\u003e\n 3\u003cbr\u003e\n 10 20 30\u003cbr\u003e\n 0 100 200\u003cbr\u003e\n 100 0 300\u003cbr\u003e\n 200 300 0\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eSample Output\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003e370\u003cbr\u003e\n\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n\u003c/p\u003e\n"}}]}