随笔分类 - DP
摘要:一、区间DP 1. 石子合并 (1) 相邻成圈取🏐:这道让我一直纠结于dp的最优子结构和贪心的局部最优,实际上到现在还不太能讲清楚,不过,像田忌赛马一样? 思路是:把圈石头变成直石头,以两堆合并到n堆合并为阶段,从l堆到r堆合并为状态,判断用k在l r之间分割并判断为决策。 1 #include<
阅读全文
摘要:https://www.luogu.org/problemnew/show/P1240 行列不重复-->每一列放置的种类数跟前一列有关(递推)-->镜面和旋转的情况属于不同的方案-->按每列长度从小到大排-->得到第(2*i-1)和第(2*i)列长度相同,第(2*n-1)列长度最长且唯一,奇数列长度
阅读全文
摘要:https://www.luogu.org/problemnew/show/P1216 从底往上推,每一个记录的都是下面两个中最大的路径和。 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 #include<cstrin
阅读全文
摘要:https://www.luogu.org/problemnew/show/P1113 用DP来写,下次加拓扑 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 #include<cstring> 5 #include<c
阅读全文
摘要:https://vjudge.net/problem/18374/origin 1 #include<cstdio> 2 #include<algorithm> 3 #include<iostream> 4 #include<cmath> 5 using namespace std; 6 const
阅读全文

浙公网安备 33010602011771号