随笔分类 -  dp

摘要:题:https://codeforces.com/contest/1257/problem/E 题意:给定3个数组,可行操作:每个数都可以跳到另外俩个数组中去,实行多步操作后使三个数组拼接起来形成升序。 输出最小操作次数 dp: #include<bits/stdc++.h> using names 阅读全文
posted @ 2019-11-15 10:42 starve_to_death 阅读(149) 评论(0) 推荐(0)
摘要:题:https://codeforces.com/contest/1027/problem/E 题意:给定n*n的方格,可以染黑白,要求相邻俩行”完全“不同或完全相同,对于列也是一样。然后限制不能拥有k面积具有相同颜色的格子 分析: #include<bits/stdc++.h> using nam 阅读全文
posted @ 2019-11-11 12:52 starve_to_death 阅读(194) 评论(0) 推荐(0)
摘要:E:https://codeforces.com/contest/1088/problem/E dp+贪心 题目大意:选择一个k并且选择k个连通块,要求sigma a[i]/k最大,k尽量大,对于给定的一颗树,输出最大的分数,不用约分的形式。题目意思需要进一步解析,假定有一个最大的连通块,那么根据贪 阅读全文
posted @ 2019-11-06 14:26 starve_to_death 阅读(150) 评论(0) 推荐(0)
摘要:题:https://codeforces.com/contest/1256/problem/E 题意:给一些值,代表队员的能力值,每组要分3个或3个以上的人,然后有个评价值x=(队里最大值-最小值),问最小的∑x是多少,以及输出方案 学习粗:https://www.cnblogs.com/Lubix 阅读全文
posted @ 2019-11-05 22:10 starve_to_death 阅读(226) 评论(0) 推荐(0)
摘要:题:https://codeforces.com/contest/1249/problem/F 题意:给一颗树,边权为1,节点有点权,问取到一个点集,俩俩之间路径超过k,是点权和最大 思路:贪心地取点,先将点按照深度经行排序,每一次,取一个点权大于0的点,然后对于这个点bfs出去的路径小于k的点减去 阅读全文
posted @ 2019-10-23 20:10 starve_to_death 阅读(331) 评论(0) 推荐(0)
摘要:题:https://codeforces.com/contest/1241/problem/E 题目大意:给你一棵树,每一个点都可以染k种颜色,你拥有无数种颜色,每一种颜色最多使用2次,如果一条边的两个节点拥有同一种颜色,那么就说 这条边是饱和的,一个树的价值定义为饱和边的权值之和,问一棵树的最大价 阅读全文
posted @ 2019-10-09 23:23 starve_to_death 阅读(426) 评论(0) 推荐(1)
摘要:题意: 如果p数组中 下标i<j且pi>pj 那么点i j之间存在一条边 现在已经知道边,然后求p数组 在一张图中,求有多少个点集,使得这个点集里面的任意两点没有边 不在点集里面的点至少有一条边连向点集中一点 思路: 我们考虑一条边 (i,j)那么定义在一个序列中(i,j)为一个逆序对(i,j)那么 阅读全文
posted @ 2019-10-04 14:27 starve_to_death 阅读(173) 评论(0) 推荐(0)
摘要:题: https://nanti.jisuanke.com/t/41414 #include<bits/stdc++.h> using namespace std; typedef __int128 ll; const int M=30; const int mod=1e9+7; ll dp[M][ 阅读全文
posted @ 2019-09-15 23:49 starve_to_death 阅读(159) 评论(0) 推荐(0)
摘要:题:https://nanti.jisuanke.com/t/41420 定义 dp[x][y] 表示第 x 个数到最后一个数能组成和为 y 的方案数 #include<bits/stdc++.h> using namespace std; typedef long long ll; const i 阅读全文
posted @ 2019-09-15 23:06 starve_to_death 阅读(278) 评论(0) 推荐(0)
摘要:题:https://nanti.jisuanke.com/t/41403 题意:求任意俩点之间距离之和模3后的三个结果的总数(原距离之和) 第一种做法: 树形dp #include<bits/stdc++.h> using namespace std; #define pb push_back ty 阅读全文
posted @ 2019-09-15 09:11 starve_to_death 阅读(189) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=3659 #include<iostream> #include<cstring> #include<algorithm> #include<cstdio> #include<vector> using namespace std; const i 阅读全文
posted @ 2019-07-11 09:12 starve_to_death 阅读(179) 评论(0) 推荐(0)
摘要:http://codeforces.com/contest/1187/problem/E 分析:问得分最高,实际上就是问以哪个节点出发得到的分数最多,而呈现成代码形式就变成了换根,max其得分!!!而要利用之前算过的得分来求。 #include<bits/stdc++.h> using namesp 阅读全文
posted @ 2019-07-10 20:03 starve_to_death 阅读(296) 评论(0) 推荐(0)
摘要:https://codeforces.com/contest/1173/problem/D 题意: 给出你一个包含 n 个点的树,这 n 个点编号为 1~n; 给出一个圆,圆上放置 n 个位置,第 i 个位置对应树中的某个节点,并且不重复; 求在圆上还原这棵树后,使得边不相交的总方案数; 学习出:h 阅读全文
posted @ 2019-06-09 10:10 starve_to_death 阅读(251) 评论(0) 推荐(0)
摘要:#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #include<vector> using namespace std; // push_back inline in 阅读全文
posted @ 2019-06-01 23:15 starve_to_death 阅读(165) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=2342 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #include<vector> using namesp 阅读全文
posted @ 2019-06-01 22:35 starve_to_death 阅读(122) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2019-06-01 22:08 starve_to_death 阅读(10) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3507 解释:当且仅当g【j,k】程璐,j对dp【i】的更新由于k对dp【i】的; 解释:对于第2点,因为单调队列维护的要是斜率上升的数据结构;所以要做此循环 对于第3点,因为是斜率上升的数据结构,所以如果满足持续 阅读全文
posted @ 2019-05-22 23:50 starve_to_death 阅读(134) 评论(0) 推荐(0)
摘要:https://codeforces.com/contest/1154/problem/F 给定m个折扣 每个折扣的{x,y}的意思是每次购买如果买到确切的x只铲子就其中的最便宜的y只铲子免付; 先贪心一波,因为要买k只,而不管折扣怎么变,怎么买,我们都要买原价最便宜的k只铲子,这贪心是对的 接着就 阅读全文
posted @ 2019-04-17 23:00 starve_to_death 阅读(178) 评论(0) 推荐(0)