随笔分类 -  区间 dp

摘要:洛谷传送门 CF 传送门 虚高 *2800。放模拟赛 T2 人均切了。 考虑拎出环上的点,每个点下面都挂了一棵树。 那么可以预处理出每棵树从一个点开始染黑,这棵树对答案的贡献。因为一棵树染了一个点就只能去染子树了,所以这个贡献是固定的,用换根 dp 求即可。 那么我们现在可以在环上选择一个起点,每次 阅读全文
posted @ 2024-01-23 11:29 zltzlt 阅读(9) 评论(0) 推荐(0) 编辑
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF888F "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/888/F "CF 传送门") 做做简单题放松身心。 考虑区间 dp,设 $f_{i 阅读全文
posted @ 2023-07-31 23:30 zltzlt 阅读(17) 评论(0) 推荐(0) 编辑
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_keyence2021_e "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/keyence2021/tasks/keyence2021_e "AtCoder 阅读全文
posted @ 2023-07-06 16:18 zltzlt 阅读(10) 评论(0) 推荐(0) 编辑
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_arc153_e "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/arc153/tasks/arc153_e "AtCoder 传送门") 我们考虑给定 $X 阅读全文
posted @ 2023-07-03 21:05 zltzlt 阅读(17) 评论(0) 推荐(0) 编辑
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc238_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc238/tasks/abc238_h "AtCoder 传送门") 考虑期望转计数,方 阅读全文
posted @ 2023-06-27 13:34 zltzlt 阅读(37) 评论(0) 推荐(0) 编辑
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc219_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc219/tasks/abc219_h "AtCoder 传送门") 套路化了。 比较显 阅读全文
posted @ 2023-06-14 21:47 zltzlt 阅读(23) 评论(0) 推荐(0) 编辑
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc303_g "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc303/tasks/abc303_g "AtCoder 传送门") 经典题,考虑区间 阅读全文
posted @ 2023-05-28 19:19 zltzlt 阅读(105) 评论(0) 推荐(0) 编辑
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_agc062_b "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/agc062/tasks/agc062_b "AtCoder 传送门") 妙妙题。 像这种最 阅读全文
posted @ 2023-05-22 10:50 zltzlt 阅读(30) 评论(0) 推荐(0) 编辑
摘要:洛谷传送门 AtCoder 传送门 考虑连边 (i,pi)(若 pi=1 则不连边),可以发现形成了一篇内向树森林且这个森林存在一个 dfs 序为 1,2,...,n。 这棵森林有如下性质: vsonu,hu>hv $\forall v, 阅读全文
posted @ 2023-04-16 09:57 zltzlt 阅读(14) 评论(0) 推荐(0) 编辑
该文被密码保护。
posted @ 2022-07-15 16:41 zltzlt 阅读(1) 评论(0) 推荐(0) 编辑
摘要:洛谷传送门 CF 传送门 思路 考虑区间 dp。设 fi,j 为只考虑区间 [l,r] 的点的最小值。转移就考虑计算每条边的贡献,枚举根,则根到左子树的这条边的贡献即为左子树的点为 i,非左子树的点为 j 的所有 ci,j 的和。右子树同理。二维前缀和预处理一下即可做 阅读全文
posted @ 2022-07-13 21:12 zltzlt 阅读(110) 评论(0) 推荐(0) 编辑
摘要:洛谷传送门 思路 区间 dp。设 fl,r 为子串 [l,r] 压缩的最短长度,显然有 fl,rmini=lr1fl,i+fi+1,r。还要考虑压缩 [l,r] 的情况。 设 \(fail_{i 阅读全文
posted @ 2022-06-22 11:00 zltzlt 阅读(38) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示