随笔分类 -  记忆化&动态规划

摘要:Aimee 他的状态转移有手就行 但是需要写高精 #include<iostream> #include<cstdio> #include<algorithm> #include<bits/stdc++.h> using namespace std; struct Aimee{ int len; i 阅读全文
posted @ 2020-11-05 21:53 Simex 阅读(86) 评论(0) 推荐(0)
摘要:Aimee 一个很水的背包 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; int n; int dp[10001]; int num[10001]; int 阅读全文
posted @ 2020-10-31 20:00 Simex 阅读(93) 评论(0) 推荐(0)
摘要:Aimee 这个题的数据范围$O(n^2)$ 过不去,但是这可是排列啊 求出一个数组中每一个元素在第二个中的位置,然后跑LIS ``cpp #include #include #include #include using namespace std; int p[100001]; int re[1 阅读全文
posted @ 2020-10-25 21:35 Simex 阅读(56) 评论(0) 推荐(0)
摘要:Miku 这个题很显然的可以从部分分推到正解 64 上去就是一个四维dp,dp[i][j][k][z]表示在第1行的时候第一行选了j个,第2行选了k个,第3行选了z个的 情况下的方案数,转移用手就能推。 只是有个小细节 #include<iostream> #include<cstdio> #inc 阅读全文
posted @ 2020-10-25 21:15 Simex 阅读(68) 评论(0) 推荐(0)
摘要:Miku 很简单的线性dp 或者说不用dp 有两维,随便按照一维降序排个序,就成了个固定顺序的一维问题了。 直接$O(n^2)$贪心划分不下降子序列或者说运用dilworth定理,求最长上升子序列 贪心更快诶,可能是因为continue的多? dp #include<iostream> #inclu 阅读全文
posted @ 2020-10-22 23:27 Simex 阅读(127) 评论(0) 推荐(0)
摘要:Miku 很水的拓扑排序+dp 看错题除外。 这道题是要求有多少条食物链满足 左端是不会捕食其他生物的生产者,最右端是不会被其他生物捕食的消费 不是求最长的多长或者有几条最长!! (把一些无关紧要的变量起一些人名真有意思) #include<iostream> #include<queue> usi 阅读全文
posted @ 2020-10-21 23:24 Simex 阅读(67) 评论(0) 推荐(0)
摘要:所谓年轻,就是意识不到自己的年轻 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; unsigned long long n,m; unsigned long 阅读全文
posted @ 2020-10-17 20:54 Simex 阅读(84) 评论(0) 推荐(0)
摘要:Miku 很水的一个背包 #include<iostream> #include<cstring> #include<algorithm> #define int long long using namespace std; int n,k; int Ariche[1001][1001]; int 阅读全文
posted @ 2020-10-17 20:12 Simex 阅读(66) 评论(0) 推荐(0)
摘要:Miku 很好的坑题,务必注意因为负边权和求路径的问题,这里需要同时用到两种方法,搜索和dp。 对于原来的情况,事实上就是每一条边都要走两次,(毕竟你还要回来啊) 但是你要是建了一条边,就会形成一个环,那么这辆车就可以直接走回去了(沿着这个圈回到出发点,也就是说,少了一条边长度的距离) 那么怎么搞呢 阅读全文
posted @ 2020-10-17 19:42 Simex 阅读(100) 评论(0) 推荐(1)
摘要:Miku 一道非常简单的dp,除非像我一样看错题 以为是所有猪全杀 然后写了个贪心,然后滚蛋 不过显然可以证明的是,优先取体重下降的快的猪,然后贪心 #include<iostream> #include<cstdio> #include<algorithm> using namespace std 阅读全文
posted @ 2020-10-05 15:26 Simex 阅读(109) 评论(0) 推荐(0)
摘要:链接:Miku $dp_{i,j,k,0/1}$表示A串 ##应该 取i,j个的时候的方案数 然后要考虑的就是 如果$a_$==\(b_{j-1}\) 那么$dp_{i,j,k,1}$=\(dp_{i-1,j-1,k,1}\)+\(dp_{i-1,j-1,k-1,1}\)+\(dp_{i-1,j-1 阅读全文
posted @ 2020-09-19 21:40 Simex 阅读(108) 评论(0) 推荐(0)
摘要:链接Miku 数位dp,定义$dp_{i,j,k}$为到了第i位有j个零并且有k个前导零的方案数 #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #include<iostream> using names 阅读全文
posted @ 2020-09-01 21:29 Simex 阅读(87) 评论(0) 推荐(0)
摘要:题目链接Miku 数论dp的典型例题 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> using namespace std; int dp[1001][15]; // 阅读全文
posted @ 2020-08-28 21:50 Simex 阅读(81) 评论(0) 推荐(0)
摘要:Miku 可以用树上dp解决 $dp_{i,j}$表示以i为根的子树在模三意义下到i的距离为j的点有几个 然后根据乘法原理搞一波 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; int n; i 阅读全文
posted @ 2020-08-22 20:38 Simex 阅读(82) 评论(0) 推荐(0)
摘要:Miku 用$dp_{i,j,z}$表示在第i行有j列一炮,z列二炮时的方案数 自己做的时候t飞了三个点 然后发现需要写一个更快的读入优化 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; lon 阅读全文
posted @ 2020-08-22 14:01 Simex 阅读(86) 评论(0) 推荐(0)
摘要:Miku 这道题样例错了!!! 正确解决方法 ⇒ 写一个搜索 ⇒ TLE ⇒进行记忆化改造 ⇒ Ac #include<iostream> #include<cstring> #include<algorithm> using namespace std; const int maxn =15; c 阅读全文
posted @ 2020-08-13 22:03 Simex 阅读(94) 评论(0) 推荐(0)
摘要:Miku 这个题目还是挺水得 正确解决方法 \(\Rightarrow\) 写一个搜索 \(\Rightarrow\) TLE $\Rightarrow$进行记忆化改造 \(\Rightarrow\) Ac 记忆化搜索和dp个人感觉有个区别就是记忆化是从下往上,dp是从上往下 #include<io 阅读全文
posted @ 2020-08-13 20:20 Simex 阅读(122) 评论(0) 推荐(0)
摘要:[MIku](https://www.luogu.com.cn/problem/P2758) 定义$dp_{i,j}$为把$A_{1-i}$变为$B_{1-j}$得最小花费 可以由$dp_{i-1,j}$转移,把$A_$删了 \(dp_{i,j-1}\) 最后加个$B_$ \(dp_{i-1,j-1 阅读全文
posted @ 2020-08-12 22:11 Simex 阅读(140) 评论(0) 推荐(0)
摘要:Miku 既然是二分图匹配的模板 为什么不和模板一样是绿的 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; struct b{ int to; int ne; 阅读全文
posted @ 2020-08-07 22:42 Simex 阅读(177) 评论(0) 推荐(0)
摘要:Miku 真是自闭呢 这个题还是还理解的 dfs预处理出每一行的情况,然后dp #include<iostream> #include<cstdio> using namespace std; int ok[2001]; int n,kk; long long dp[10][2001][2001]; 阅读全文
posted @ 2020-08-07 22:41 Simex 阅读(90) 评论(0) 推荐(0)