POJ 2485-Highways 最小生成树Prim算法
来源:互联网 发布:有什么软件程序 编辑:程序博客网 时间:2024/04/18 02:59
题目来源:http://acm.pku.edu.cn/JudgeOnline/problem?id=2485
解题报告:
还是最小生成树问题,Prim算法实现,没用到priority_queue或是set,还是直接用O(n)复杂度来寻找key中的最小值。这道题很基础,纯粹用来熟练Prim算法。
附录:
Highways
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 9754 Accepted: 4580
Description
The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Flatopian government is aware of this problem. They're planning to build some highways so that it will be possible to drive between any pair of towns without leaving the highway system.
Flatopian towns are numbered from 1 to N. Each highway connects exactly two towns. All highways follow straight lines. All highways can be used in both directions. Highways can freely cross each other, but a driver can only switch between highways at a town that is located at the end of both highways.
The Flatopian government wants to minimize the length of the longest highway to be built. However, they want to guarantee that every town is highway-reachable from every other town.
Flatopian towns are numbered from 1 to N. Each highway connects exactly two towns. All highways follow straight lines. All highways can be used in both directions. Highways can freely cross each other, but a driver can only switch between highways at a town that is located at the end of both highways.
The Flatopian government wants to minimize the length of the longest highway to be built. However, they want to guarantee that every town is highway-reachable from every other town.
Input
The first line of input is an integer T, which tells how many test cases followed.
The first line of each case is an integer N (3 <= N <= 500), which is the number of villages. Then come N lines, the i-th of which contains N integers, and the j-th of these N integers is the distance (the distance should be an integer within [1, 65536]) between village i and village j. There is an empty line after each test case.
The first line of each case is an integer N (3 <= N <= 500), which is the number of villages. Then come N lines, the i-th of which contains N integers, and the j-th of these N integers is the distance (the distance should be an integer within [1, 65536]) between village i and village j. There is an empty line after each test case.
Output
For each test case, you should output a line contains an integer, which is the length of the longest road to be built such that all the villages are connected, and this value is minimum.
Sample Input
130 990 692990 0 179692 179 0
Sample Output
692
Hint
- 最小生成树Prim算法 Highways POJ
- POJ 2485-Highways 最小生成树Prim算法
- POJ 2485 Highways 图论 prim算法 最小生成树
- POJ 2485 Highways 最小生成树 prim算法
- POJ 2485 Highways(最小生成树prim算法)
- poj 2485 Highways prim最小生成树
- POJ 2485 Highways (prim最小生成树)
- POJ 2485 Highways 【最小生成树Prim】
- poj 1751 Highways ( 最小生成树--prim算法 )
- POJ 1751 Highways(最小生成树prim)
- poj 1751 Highways 最小生成树 prim
- POJ 2485 Highways(prim 最小生成树)
- POJ 2485 Highways(最小生成树 Prim)
- poj 2485 Highways(kruscal or prim最小生成树)
- POJ 2485:Highways:典型prim最小生成树(2)
- poj 2485 Highways(prim求最小生成树)
- POJ 2485:Highways(最小生成树&&prim)
- poj 2485 Highways(最小生成树,prim)
- Cookies和Session(二)
- Java设计模式 Design Pattern:模板方法 Template Method
- ARM 汇编中跳转指令
- Office技巧--怎样清除Outlook邮件地址 在word里换页
- Cookies和Session(三)--SessionState
- POJ 2485-Highways 最小生成树Prim算法
- Swing与多线程-小结
- C#自定义项目模板(即VC自定义向导)的两种方法
- asp.net表单提交方法GET/POST
- linux压缩命令小结
- tinymce编辑器的光标位置插入内容时,光标丢失问题解决办法
- 如何避免打开键盘或横竖屏切换,active重启,处理界面的延迟动画
- Vector
- VC调试手段