![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
DP
Konago
这个作者很懒,什么都没留下…
展开
-
TSP(旅行商问题)-状压dp
给定n个点(0...n - 1)的带权有向图,出从0出发经过每点恰好一次再回到的0,求所经过的边的总权值的最小值 n 方程为:dp[S][v] = min(dp[S + u][u], map[v][u]) dp[S][v]指的是已经经过S集合中的点(包括v),从v出发回到0所需要的最小权值; 因为上述的dp方程中,第一个下标是集合不是整数,不好直接做,那怎么办呢, 1:把各个S所原创 2017-10-13 00:59:26 · 1390 阅读 · 0 评论 -
hdu 3681 Prison Break
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3681 题意:n*m矩阵有加起来不超过十五个的G和Y,你需要走过所有的Y,移动一次需要一电量,问最少需要多大的电池。 思路:如果没有G,就是一个很简单的最短路了,有了G就很复杂,我们二分讨论V,用状压dp做辅助,dp[S][k] = max(dp[S+{j}][j] - dis[j][k]) ...原创 2017-10-31 01:46:25 · 298 阅读 · 0 评论 -
hdu 2546 饭卡
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2546 简单的01背包 #include #include #include #include #include #include using namespace std; const int maxn = 1005; int n, m, W; int dp[maxn], w[maxn原创 2018-03-08 22:19:31 · 170 阅读 · 0 评论 -
Uva 1330 City Game
https://vjudge.net/problem/UVA-1330 悬线法 #include<bits/stdc++.h> using namespace std; const int maxn = 1e3 + 50; const int inf = 1e9 + 7; int n, m, k; char M[maxn][maxn]; int up[maxn][maxn],...原创 2018-07-30 00:19:30 · 189 阅读 · 0 评论