【正文】
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 QS39。s have received the message. 西安電子科技大學(xué)計(jì)算機(jī)學(xué)院 School of Computer Science amp。 Engineering, Xidian University, China 例 6: QS Network A sample is shown below: A sample QS work, 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. 西安電子科技大學(xué)計(jì)算機(jī)學(xué)院 School of Computer Science amp。 Engineering, Xidian University, China 例 6: QS Network Each QS has its favorate brand of work adapters and always buys the brand in all of its connections. Also the distance between QS vary. Given the price of each QS39。s favorate brand of work 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 work. 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. 西安電子科技大學(xué)計(jì)算機(jī)學(xué)院 School of Computer Science amp。 Engineering, Xidian University, China 例 6: 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 integer n which indicates the number of QS. The 2nd line contains n integers, indicating the price of each QS39。s favorite work adapter. In the 3rd line to the n+2th line contain a matrix indicating the price of cable between each pair of QS. Constrains: all the integers in the input are nonnegative and not more than 1000. 1 3 10 20 30 0 100 200 100 0 300 200 300 0 Sample input 西安電子科技大學(xué)計(jì)算機(jī)學(xué)院 School of Computer Science amp。 Engineering, Xidian University, China 例 6: QS Network Output for each data set, output the minimum cost to setup a QS work. NO extra empty lines needed. Case 1:370 Output for the sample input: 1 3 10 20 30 0 100 200 100 0 300 200 300 0 Sample input 西安電子科技大學(xué)計(jì)算機(jī)學(xué)院 School of Computer Science amp。 Engineering, Xidian University, China 要求 ? 編程實(shí)現(xiàn)二叉樹的先序、中序、后序和層序遍歷算法。 ? 編程實(shí)現(xiàn)構(gòu)造最優(yōu)二叉樹完成哈夫曼編碼、譯碼處理。 ? 編程實(shí)現(xiàn)圖的深度優(yōu)先、廣度優(yōu)先遍歷算法。 ? 編程實(shí)現(xiàn)求解最小生成樹的算法。 ? 編程實(shí)現(xiàn)求解圖的最短路徑算法。 西安電子科技大學(xué)計(jì)算機(jī)學(xué)院 School of Computer Science amp。 Engineering, Xidian University, China 實(shí)例 ? zoj 1060《 Sorting It All Out》 ? 由輸入構(gòu)造有向圖,判斷是否有環(huán),判斷是否完全圖,最后冒泡排序確定輸出序列。 ? zoj 1082《 Stockbroker Grapevine 》 ? Floyd算法求最短路徑。 ? zoj 1105《 FatMouse39。s Tour 》 ? 應(yīng)用歐拉圖的性質(zhì)。 ? zoj 1203《 Swordfish》 ? 最小生成樹。 ? zoj 1119《 SPF》 ? 找圖的關(guān)節(jié)點(diǎn)。 ? zoj 1492《 Maximum Clique》 ? 找最大團(tuán)。 西安電子科技大學(xué)計(jì)算機(jī)學(xué)院 School of Computer Science amp。 Engineering, Xidian University, China 附在線試題庫: 美國中學(xué)信息學(xué)網(wǎng)站 (usaco): 強(qiáng)烈推薦 結(jié) 束