随笔分类 - 区间 dp
摘要:洛谷传送门 CF 传送门 虚高 *2800。放模拟赛 T2 人均切了。 考虑拎出环上的点,每个点下面都挂了一棵树。 那么可以预处理出每棵树从一个点开始染黑,这棵树对答案的贡献。因为一棵树染了一个点就只能去染子树了,所以这个贡献是固定的,用换根 dp 求即可。 那么我们现在可以在环上选择一个起点,每次
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF888F "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/888/F "CF 传送门") 做做简单题放松身心。 考虑区间 dp,设 $f_{i
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_keyence2021_e "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/keyence2021/tasks/keyence2021_e "AtCoder
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_arc153_e "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/arc153/tasks/arc153_e "AtCoder 传送门") 我们考虑给定 $X
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc238_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc238/tasks/abc238_h "AtCoder 传送门") 考虑期望转计数,方
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc219_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc219/tasks/abc219_h "AtCoder 传送门") 套路化了。 比较显
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc303_g "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc303/tasks/abc303_g "AtCoder 传送门") 经典题,考虑区间
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_agc062_b "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/agc062/tasks/agc062_b "AtCoder 传送门") 妙妙题。 像这种最
阅读全文
摘要:洛谷传送门 CF 传送门 思路 考虑区间 dp。设 为只考虑区间 的点的最小值。转移就考虑计算每条边的贡献,枚举根,则根到左子树的这条边的贡献即为左子树的点为 ,非左子树的点为 的所有 的和。右子树同理。二维前缀和预处理一下即可做
阅读全文