摘要:
Trick Do we really need to visit all the states? Sometimes, the naive dp solution to a problem might take too long and too much memory. However, somet 阅读全文
摘要:
DP优化 单调队列优化 Watching Fireworks is Fun CF372C #include<bits/stdc++.h> using namespace std; typedef long long ll; ll n,m,d,i,j,k,l,r,ma,f[2][150005],g[1 阅读全文
摘要:
背包DP 二进制分组优化 考虑优化。我们仍考虑把多重背包转化成 0-1 背包模型来求解。 预处理物品数量是2的次方。且要覆盖物品数量的点。即2 n次方+1到k index = 0; for (int i = 1; i <= m; i++) { int c = 1, p, h, k; cin >> p 阅读全文
摘要:
线性DP 最长公共子序列 O(n*m)写法 int a[MAXN], b[MAXM], f[MAXN][MAXM]; int dp() { for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) if (a[i] == b[j]) f[i] 阅读全文