09 2020 档案

摘要:##题目传送门 \(dp,将矩阵的每一个格转化成一个物品,然后跑背包\) #include<iostream> #include<cstdio> #include<cstring> using namespace std; long long n,m,t,s,tot,c[10001],w[10001 阅读全文
posted @ 2020-09-14 09:16 Mr^Simon 阅读(124) 评论(0) 推荐(0)
摘要:##题目传送门 \(f_{i,j}表示到了第i位,已经擦掉了j位的最佳答案\) #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int n,c[1001],f 阅读全文
posted @ 2020-09-14 09:13 Mr^Simon 阅读(85) 评论(0) 推荐(0)
摘要:##题目传送门 \(字符串dp,f_{i,j}表示a串到第i位和b串到第j位的最小距离,转移和LCS一样\) #include<cstdio> #include<cstring> #include<iostream> #include<cmath> using namespace std; stri 阅读全文
posted @ 2020-09-14 09:09 Mr^Simon 阅读(81) 评论(0) 推荐(0)
摘要:##题目传送门 一道$dp$,$f_{i,j}$表示到第$i$位,已经踩准了$j$次的最佳答案. #include<iostream> #include<cstdio> #include<cstring> using namespace std; int n,t,s[5001],b[5001]; i 阅读全文
posted @ 2020-09-14 09:03 Mr^Simon 阅读(95) 评论(0) 推荐(0)
摘要:##题目传送门 记忆化搜索,以每个不为负数的花为根,向外扩展,找最大联通块. #include<iostream> #include<cstdio> #include<cstring> #include<map> using namespace std; int n,a[16001],tot,hea 阅读全文
posted @ 2020-09-13 22:48 Mr^Simon 阅读(171) 评论(0) 推荐(0)
摘要:##题目传送门 树形dp,$f_{i,j}$表示以i为根,子树删j条边的最少苹果数 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int n,q,head[101],si[101],m,pp,an 阅读全文
posted @ 2020-09-13 22:43 Mr^Simon 阅读(106) 评论(0) 推荐(0)
摘要:##题目传送门 一道dp,但我没推出方程,只好写记忆化搜索+剪枝. 主要说一下为什么从小到大排序,如果大的块被选择且最终得出符合题意的答案,那么后面很多状态都会被剪掉,因为答案越搜越小(应该是). #include<iostream> #include<cstdio> #include<cstrin 阅读全文
posted @ 2020-09-13 21:11 Mr^Simon 阅读(101) 评论(0) 推荐(1)
摘要:##题目传送门 两维限制的背包,$f_{i,j}$表示重力为i,阻力为j的最长时间,和01背包一样转移,最后用一个数组保存一下方案即可 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int m,v 阅读全文
posted @ 2020-09-12 21:51 Mr^Simon 阅读(131) 评论(0) 推荐(0)
摘要:##题目传送门 源点向每个试题连容量为1的边,试题向试题类型连容量为1的边,试题类型向汇点连容量为本类型所需题数的边.跑最大流 #include<iostream> #include<cstdio> #include<cstring> #include<queue> #include<vector> 阅读全文
posted @ 2020-09-12 21:47 Mr^Simon 阅读(155) 评论(0) 推荐(0)
摘要:##题目传送门 类比最长公共子序列,$f_{i,j,k}$表示到$A_i,B_j,C_k$的最大答案,然后跟最长公共自序列一样转移即可 #include<iostream> #include<cstdio> #include<cstring> using namespace std; string 阅读全文
posted @ 2020-09-12 21:36 Mr^Simon 阅读(164) 评论(0) 推荐(0)
摘要:##题目传送门 $f_{i,j}\(表示以\)(i,j)$为左下角能得到的最大正方形的边长. #include<iostream> #include<cstdio> #include<cstring> using namespace std; int n,t,f[1001][1001],ans; b 阅读全文
posted @ 2020-09-12 21:29 Mr^Simon 阅读(96) 评论(0) 推荐(0)
摘要:##题目传送门 源点到i单位的连容量为$r_i$的边,单位到每个餐桌连容量为1的边,餐桌j到汇点连容量为$c_j$的边,跑最大流 #include<iostream> #include<cstdio> #include<cstring> #include<vector> #include<queue 阅读全文
posted @ 2020-09-12 21:26 Mr^Simon 阅读(116) 评论(0) 推荐(0)
摘要:##题目传送门 源点向每个英国飞行员连容量为1的边,英国飞行员向每个外籍飞行员连容量为inf的边,外籍飞行员向汇点连容量为1的边,跑最大流. #include<iostream> #include<cstdio> #include<cstring> #include<queue> #include< 阅读全文
posted @ 2020-09-12 21:17 Mr^Simon 阅读(78) 评论(0) 推荐(0)
摘要:##题目传送门 板子不解释 #include<iostream> #include<cstdio> #include<cstring> #include<queue> #include<vector> #define pd(i) (i % 2 == 1) ? i + 1 : i - 1 #defin 阅读全文
posted @ 2020-09-12 21:12 Mr^Simon 阅读(87) 评论(0) 推荐(0)
摘要:##题目传送门 分别f[i][1/0]表示到第i位从前面或从后面子序列的最大和,最后枚举断点即可. #include<iostream> #include<cstdio> #include<cstring> using namespace std; int n; long long f[100000 阅读全文
posted @ 2020-09-12 21:09 Mr^Simon 阅读(150) 评论(0) 推荐(0)
摘要:##题目传送门 ##题目传送门2 f[i]表示到第i位最少要删的字符数,对于每个i,将其作为最后一位向前跟w个单词匹配,如果向前匹配到第k位,那就用f[k-1]转移,在匹配过程中记录需要删去元素的个数. #include<iostream> #include<cstdio> #include<cst 阅读全文
posted @ 2020-09-12 20:57 Mr^Simon 阅读(99) 评论(0) 推荐(0)
摘要:##题目传送门 期望dp,f[i]表示到第i位,1~n的期望收益. 对于每一位,如果操作成1,那收益就会变成: \((x+1)^3 = (x+1)^2(x+1) = (x^2+2x+1)(x+1) = x^3+3x^2+3x+1\) 显然我们在这一位获得的收益为$3x^2+3x+1$,不难发现,这是 阅读全文
posted @ 2020-09-06 22:08 Mr^Simon 阅读(95) 评论(0) 推荐(0)
摘要:题目传送门 RMQ模板题,st表分分钟AC #include<iostream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; int m,n,f[100001][30],l,r; int main() 阅读全文
posted @ 2020-09-02 23:36 Mr^Simon 阅读(119) 评论(0) 推荐(0)
摘要:题目传送门 先跑dfs,枚举出所有符合题意的符号放置方式,再跑区间dp. #include<iostream> #include<cstdio> #include<cstring> using namespace std; int n,k,a[20],p[30]; long long ans,f[2 阅读全文
posted @ 2020-09-02 23:33 Mr^Simon 阅读(258) 评论(0) 推荐(0)
摘要:题目传送门 f[i]表示到第i个信徒的最少集体数,ans[i]为最小危险值. #include<iostream> #include<cstdio> #include<cstring> #include<set> using namespace std; int n,m,k,p[1001],f[10 阅读全文
posted @ 2020-09-02 23:30 Mr^Simon 阅读(221) 评论(0) 推荐(0)
摘要:题目传送门 f[i][1/0]表示到第i列左右端点的最短路程长度 #include<iostream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; int n,l[20001],r[20001],f[ 阅读全文
posted @ 2020-09-02 23:25 Mr^Simon 阅读(122) 评论(0) 推荐(0)
摘要:题目传送门 背包,一个高精度dp #include<iostream> #include<cstdio> #include<cstring> using namespace std; int n,k; struct kkk{ int a[1000],len; kkk() { memset(a,0,s 阅读全文
posted @ 2020-09-02 23:23 Mr^Simon 阅读(185) 评论(0) 推荐(0)
摘要:题目传送门 移动一个数可以看做将其删掉,最终保留一个和最大的上升子序列 阅读全文
posted @ 2020-09-02 23:21 Mr^Simon 阅读(144) 评论(0) 推荐(0)
摘要:题目传送门 f[i][j][1/0]表示以(i,j)为右下角,当前格子是1/0的最大答案 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int n,m,ans,a[1501][1501],f[15 阅读全文
posted @ 2020-09-02 23:16 Mr^Simon 阅读(174) 评论(0) 推荐(0)
摘要:题目传送门 f[i][1/0][1/0]表示到第i列时,第i列是否放,第i-1列是否放的方案数. #include<iostream> #include<cstdio> #include<cstring> using namespace std; int n,a[10001],f[10001][2] 阅读全文
posted @ 2020-09-02 23:14 Mr^Simon 阅读(142) 评论(0) 推荐(0)
摘要:题目传送门 dp,f[i][j][k][1/0]表示到(i,j)uim/小a魔瓶里的液体为k(经取模后)的方案数 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int n,m,k,a[801][8 阅读全文
posted @ 2020-09-02 23:11 Mr^Simon 阅读(152) 评论(0) 推荐(0)
摘要:题目传送门 数位dp #include<iostream> #include<cstdio> #include<cstring> using namespace std; long long n,f[70][2][70]; long long s[70],len,mod = 10000007; in 阅读全文
posted @ 2020-09-02 23:07 Mr^Simon 阅读(154) 评论(0) 推荐(0)
摘要:题目传送门 数位dp #include<iostream> #include<cstdio> #include<cstring> using namespace std; long long a,b,f[20][2][200][205]; int s[25],len; inline long lon 阅读全文
posted @ 2020-09-02 23:06 Mr^Simon 阅读(108) 评论(0) 推荐(0)
摘要:题目传送门 数位dp #include<iostream> #include<cstdio> #include<cstring> using namespace std; int l,r,s[101],len; int f[100][2][2][100][100]; inline void fenj 阅读全文
posted @ 2020-09-02 23:05 Mr^Simon 阅读(101) 评论(0) 推荐(0)
摘要:题目传送门 数位dp. #include<iostream> #include<cstdio> #include<cstring> #define mod 1000000007 using namespace std; string l,r; int a[1005],b[1005],f[1005][ 阅读全文
posted @ 2020-09-02 23:04 Mr^Simon 阅读(105) 评论(0) 推荐(0)
摘要:题目传送门 数位dp,没啥好说的 #include<iostream> #include<cstdio> #include<cstring> #define mod 1000000007 using namespace std; int t,s[20],len; long long l,r,ans, 阅读全文
posted @ 2020-09-02 22:59 Mr^Simon 阅读(147) 评论(0) 推荐(0)
摘要:题目传送门 从最后倒着往前推,贪心模拟即可 #include<iostream> #include<cstdio> #include<vector> #include<queue> using namespace std; int m,n,ti,o[501],ans; vector<int> a[5 阅读全文
posted @ 2020-09-02 22:58 Mr^Simon 阅读(168) 评论(0) 推荐(0)
摘要:题目传送门 一开始没看到题目下面的说明(只能走直线),推了好长时间没推出来.f[i][j]表示从(0,0)到(i,j)的最大矿数. #include<iostream> #include<cstdio> #include<cstring> using namespace std; int n,m,a 阅读全文
posted @ 2020-09-02 22:54 Mr^Simon 阅读(91) 评论(0) 推荐(0)
摘要:题目传送门 区间DP,f[i][j]表示i~j区间最小答案,用ans[i][j]记录f[i][j]的断点在哪里,即括号分界处. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namesp 阅读全文
posted @ 2020-09-02 21:43 Mr^Simon 阅读(125) 评论(0) 推荐(0)
摘要:题目传送门 分层图最短路,或者说是一个DP,f[i][j]表示用了i张免费券,到了j号点的最小花费,然后跑最短路 #include<iostream> #include<cstdio> #include<cstring> #include<queue> using namespace std; in 阅读全文
posted @ 2020-09-02 21:14 Mr^Simon 阅读(239) 评论(0) 推荐(0)