floyd,旅游问题每个点都要到,可重复,最后回来,dp http://poj.org/problem?id=3311 Hie with the Pie Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4013   Accepted: 2132 Description The Pizazz Pizzeria prides itself in delivering pizzas to its customers as fas…
题意:类似于TSP问题,只是每个点可以走多次,求回到起点的最短距离(起点为点0). 分析:状态压缩,先预处理各点之间的最短路,然后sum[i][buff]表示在i点,状态为buff时所耗时....... 所以把10 * 1024 种状态来一遍,取sum[0][(1<<n)-1]的最小值 只是把状态压缩DP改成bfs+状态压缩了 #include <cstdio> #include <iostream> #include <cstring> #include…
Hie with the Pie Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4491   Accepted: 2376 Description The Pizazz Pizzeria prides itself in delivering pizzas to its customers as fast as possible. Unfortunately, due to cutbacks, they can affo…
题目链接:http://poj.org/problem?id=3311 Description The Pizazz Pizzeria prides itself in delivering pizzas to its customers as fast as possible. Unfortunately, due to cutbacks, they can afford to hire only one driver to do the deliveries. He will wait fo…
链接:http://poj.org/problem?id=3311 题意:有N个地点和一个出发点(N<=10),给出全部地点两两之间的距离,问从出发点出发,走遍全部地点再回到出发点的最短距离是多少. 思路:首先用floyd找到全部点之间的最短路.然后用状态压缩,dp数组一定是二维的,假设是一维的话不能保证dp[i]->dp[j]一定是最短的.由于dp[i]记录的"当前位置"不一定是能使dp[j]最小的当前位置.所以dp[i][j]中,i表示的二进制下的当前已经经过的状态,j…
Hie with the Pie Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4671   Accepted: 2471 Description The Pizazz Pizzeria prides itself in delivering pizzas to its customers as fast as possible. Unfortunately, due to cutbacks, they can affo…
Hie with the Pie Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11243   Accepted: 5963 Description The Pizazz Pizzeria prides itself in delivering pizzas to its customers as fast as possible. Unfortunately, due to cutbacks, they can aff…
题目链接:http://poj.org/problem?id=3311 题目大意:一个送披萨的,每次送外卖不超过10个地方,给你这些地方之间的时间,求送完外卖回到店里的总时间最小. Sample Input 3 0 1 10 10 1 0 1 2 10 1 0 10 10 2 10 0 0 Sample Output 8 分析:dp[i][j]:表示在i状态(用二进制表示城市有没有经过)时最后到达j城市的最小时间,转移方程:dp[i][j]=min(dp[i][k]+d[k][j],dp[i][…
主题连接:  id=3311">http://poj.org/problem?id=3311 题目大意:有n+1个点,给出点0~n的每两个点之间的距离,求这个图上TSP问题的最小解 思路:用二进制数来表示訪问过的城市集合.f[{S}][j]=已经訪问过的城市集合为S,訪问了j个城市.所需的最少花费. 这里提一下二进制数表示集合的方法(这里最好还是设集合中最多有n个元素): 假设集合S中最多会出现n个元素,则用长度为n的二进制数来表示集合S,每一位代表一个元素.该位为0表示该元素在集合S…
题目链接:http://poj.org/problem?id=3311 题意: 你在0号点(pizza店),要往1到n号节点送pizza. 每个节点可以重复经过. 给你一个(n+1)*(n+1)的邻接矩阵,表示各点之间距离. 问你送完所有pizza再返回店里的最短路程. 题解: 与传统TSP相比,唯一变化的条件是每个节点可以经过多次. 所以也就是转移的时候不用再判断要去的节点j是否去过. 先floyd预处理出两点之间最短路.然后把(!((state>>j)&1))去掉,套TSP模板就好…