{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv\u003e\n Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course.\n \u003cbr\u003e Farmer John ordered a high speed connection for his farm and is going to share his connectivity with the other farmers. To minimize cost, he wants to lay the minimum amount of optical fiber to connect his farm to all the other farms.\n \u003cbr\u003e Given a list of how much fiber it takes to connect each pair of farms, you must find the minimum amount of fiber needed to connect them all together. Each farm must connect to some other farm such that a packet can flow from any one farm to any other farm.\n \u003cbr\u003e The distance between any two farms will not exceed 100,000.\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv\u003e\n The input includes several cases. For each case, the first line contains the number of farms, N (3 \u0026lt;\u003d N \u0026lt;\u003d 100). The following lines contain the N x N \n \u003cspan\u003econectivity\u003c/span\u003e matrix, where each element shows the distance from on farm to another. Logically, they are N lines of N space-separated integers. Physically, they are limited in length to 80 characters, so some lines continue onto others. Of course, the diagonal will be 0, since the distance from farm i to itself is not interesting for this problem.\n\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv\u003e\n For each case, output a single integer length that is the sum of the minimum length of fiber required to connect the entire set of farms.\n\u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e\r\n4\r\n0 4 9 21\r\n4 0 8 17\r\n9 8 0 16\r\n21 17 16 0\r\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e\r\n28\u003c/pre\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cdiv\u003e\n \u0026nbsp;\n\u003c/div\u003e \n\u003cdiv\u003e\n 最小生成树的基本题\n\u003c/div\u003e \n\u003cdiv\u003e\n 两种算法板子套上一个就过了\n\u003c/div\u003e \n\u003cdiv\u003e\n 思考最大生成树如何实现;\n\u003c/div\u003e \n\u003cdiv\u003e\n 思考非同构的最小生成树的数量;\n\u003c/div\u003e \n\u003cdiv\u003e\n 思考如果规定了一些点的最大出度,该如何实现最小生成树;\n\u003c/div\u003e \n\u003cdiv\u003e\n 关于树的题目很多,思考如果将第三章的DP和第三章的贪心结合起来能解决那些问题?\n\u003c/div\u003e \n\u003cdiv\u003e\n 等等。。。。。\n\u003c/div\u003e"}}]}