poj 3311(floyd+状态压缩)
来源:互联网 发布:mac平台 编辑:程序博客网 时间:2024/06/05 04:20
题目链接:http://poj.org/problem?id=3311
思路:Floyd + 状态压缩DP
题意是有N个城市(1~N)和一个PIZZA店(0),要求一条回路,从0出发,又回到0,而且距离最短 (可重复走).
首先不难想到用FLOYD先求出任意2点的距离dis[i][j] 。
接着枚举所有状态,用11位二进制表示10个城市和pizza店,1表示经过,0表示没有经过 。
定义状态DP(S,i)表示在S状态下,到达城市I的最优值 。
接着状态转移方程:DP(S,i) = min{DP(S^(1<<i-1),k) + dis[k][i],DP(S,i)},器重S^(1<<i-1)表示未到达城市i的所有状态,1<=k<=n 。
对于全1的状态,即S = (1<<n)-1则表示经过所有城市的状态,最终还需要回到PIZZA店0 。
那么最终答案就是min{DP(S,i) + dis[i][0]} 。
0 0
- poj 3311(floyd+状态压缩)
- POJ 3311 Hie with the Pie(Floyd+状态压缩DP)
- POJ 3311 Hie with the Pie (Floyd+状态压缩)
- POJ 3311 Hie with the Pie(Floyd+状态压缩DP)
- POJ 3311 Hie with the Pie(Floyd+状态压缩DP)
- poj 3311 Hie with the Pie floyd+状态压缩dp
- POJ 3311 Hie with the Pie(Floyd+状态压缩DP)
- poj 3311 Hie with the Pie(状态压缩DP+floyd)
- POJ 3311 Hie with the Pie 状态压缩DP+floyd
- poj 3311 Hie with the Pie(floyd+状态压缩)
- poj 3311 Hie with the Pie (floyd+状态压缩dp~)
- poj 3311 floyd + 状态
- Poj 2570 Fiber Network【Floyd+状态压缩】
- poj 3311 状态压缩
- (3311)POJ-状态压缩
- POJ 3311 Hie with the Pie (Floyd + 暴力全排列 || Floyd + 状态压缩DP (已补充))
- poj 3311 Hie with the Pie (floyd+状态压缩dp)
- POJ 3311 Hie with the Pie(状态压缩DP+Floyd)
- poj 1797(最短路变形)
- hdu 4618(最大回文子矩阵)
- poj 2449(A*求第K短路)
- poj 3072(最短路)
- poj 3255(次短路)
- poj 3311(floyd+状态压缩)
- poj 3328(多起点多终点的最短路)
- poj 3613(经过N条边的最短路)
- 关于cocos2dx 在wp8 中 如何显示中文
- poj 3615(floyd变形)
- hdu 4462(状态压缩)
- hdu 4628(状态压缩)
- poj 3635(bfs+优先队列)
- Linux 文件系统目录结构