pku 3311 Hie with the Pie
来源:互联网 发布:mysql insert 中文列 编辑:程序博客网 时间:2024/05/21 08:42
题目大意:
送外卖小伙想用最短的时间把商品送给所有客户,并且最后回到商店。
这道题一开始确实困扰我蛮久的,我只是凭感觉做了folyd,但是接下来怎么做不知道,看了一下别人的思路,原来枚举就可以了,但是又不知道怎么枚举……我真是悲剧,确实每次遇到枚举的题目,都不太会枚举,没有这种思路,看了别人的代码,才发现把路径全排列一下就可以了。
原理:
folyd:求出每两点之间最短路径。(算法导论)
一开始的问题:
folyd只能求出两点之间的最短路径,但是有可能1->3是要经过2的,那么2这个点经过了怎么知道?
但是后来一想,让点全排列之后,那最优解肯定是1->2->3这条路,因为1->2+2->3这条路径不可能再比1->3小,如果相等那么既保证距离不增加,也保证走了更多的点,如果大的话这组数据肯定不是最优解。
所以全排列(除了起点)肯定中间包含最优解,故枚举可以求出答案。
最后不贴代码,以后一定也不要看别人的代码!这样才能有提高!
- pku 3311 Hie with the Pie
- PKU 3311 Hie with the Pie 最短路 folyd
- Pku oj 3311 Hie with the Pie(TSP问题)
- Hie with the Pie
- Hie with the Pie
- poj 3311 Hie with the Pie
- POJ 3311 Hie with the Pie
- poj 3311 Hie with the Pie
- poj 3311 Hie with the Pie
- poj 3311 Hie with the Pie (TSP)
- POJ 3311 — Hie with the Pie
- POJ 3311 Hie with the Pie
- poj 3311 Hie with the Pie (DP)
- POJ 3311 Hie with the Pie
- POJ 3311 Hie with the Pie
- POJ - 3311 Hie with the Pie
- POJ 3311 - Hie with the Pie
- POJ 3311 Hie with the Pie
- USACO 两道题目
- WinForm程序用使用List对象绑定DataGridView数据源
- 关于单片机检测高电平
- sql server中的uuid字段转化成nvarchar类型?
- 2011-04-13 Linux驱动相关书籍
- pku 3311 Hie with the Pie
- JSP中如何使用JQuery?
- 3D引擎
- Sql FAQ
- 内存管理2
- JSP、Servlet基础
- 2236: Balance and Poise
- 自定义Theme 与 使用
- 用GVIM替代Val(a)IDE!