![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
动态规划 状压DP
文章平均质量分 77
saucyJack
外科
展开
-
poj 3311 Hie with the Pie(Floyd+状压dp)
传送门:http://poj.org/problem?id=3311 经典的旅行商问题。 dp[i][j]表示在i状态下到达j城市的最优解(i=1 dp[i][j]=min(dp[i][j],dp[i^(1 #include #include #include #include using namespace std; const int INF=0x3f3f3f3f; const原创 2016-02-15 21:38:06 · 212 阅读 · 0 评论 -
poj 3254 Corn Fields(状压DP+滚动数组)
传送门:http://poj.org/problem?id=3254 这题是状压DP的入门题吧。 用了滚动数组优化了一下,0msAC。 具体解释直接看代码: #include #include #include #include using namespace std; const int INF=0x3f3f3f3f; const int mod=100000000; const in原创 2016-02-15 09:28:29 · 262 阅读 · 0 评论 -
poj 1185 炮兵阵地(状压dp)
题目链接:http://poj.org/problem?id=1185 状压dp跑了375ms... 状态转移方程是参考网上的思路... dp[i][j][k]表示第i行状态为j,第i-1行状态为k的最优解 开一个三维数组,而大小为2*1 如果筛选出同一行内的可行状态,其实最多只有60种(可以取m最大输出stateNum即可) 状态转移方程为dp[r%2][i][j]=max(dp原创 2016-02-15 17:47:00 · 213 阅读 · 0 评论