随笔分类 -  DP

摘要:「CF1037H」Security 有关字典序可以依次考虑 T 的每一位转化为询问 O(|Σ||T|) 个字符串在区间 [l,r] 的存在性判断。因为可以用线段树合并维护 SAM 上每个等价类的 \(\t 阅读全文
posted @ 2024-09-06 22:16 little_pinkpig 阅读(19) 评论(0) 推荐(0) 编辑
摘要:heart Solution 可以记 f(u) 为从 u 出发到某个点停止的方案数,f(u) 可以 O(n) 转移,显然复杂度为 O(n2). 当前我们要转移 u 子树内 阅读全文
posted @ 2023-11-14 22:13 little_pinkpig 阅读(33) 评论(1) 推荐(0) 编辑
摘要:「GLR-R3」 惊蛰 Link Describe 给定非负整数序列 {an},定义函数 f(x,y) 为 \[f(x,y)=\begin{cases} x-y,&x\ge y\\ C,&x< y \end{ca 阅读全文
posted @ 2023-11-02 22:11 little_pinkpig 阅读(52) 评论(0) 推荐(0) 编辑
摘要:「CF848D」Shake It! Solution 我们可以发现题目中的图可以拆分为若干个递归的子结构,可以对这些子结构考虑 DP,设 f(i,j) 表示考虑对一个子结构 (s,t) 加入 i 个点后形成的图 阅读全文
posted @ 2023-10-06 20:27 little_pinkpig 阅读(55) 评论(0) 推荐(1) 编辑
摘要:#「HDU4035」 Maze Describe 迷宫有 n 个房间,由 n1 条隧道连通起来形成了一棵树,从结点 1 出发,在每个结点 i 都有 3 种可能,每种可能概率都互斥: Ki 的概率被杀死,回到结点1处; Ei 阅读全文
posted @ 2022-10-02 23:52 little_pinkpig 阅读(24) 评论(0) 推荐(1) 编辑
摘要:Codeforces Round #815 (Div.2) 「CF1720A」 Burenka Plays with Fractions Codeforces 链接 Solution 每次可以对分子分母同时乘上 k,相当于对分数乘 阅读全文
posted @ 2022-08-19 22:07 little_pinkpig 阅读(57) 评论(1) 推荐(0) 编辑
摘要:「CF1174E」 Ehab and the Expected GCD Problem Describe 给定一个有 n 个数的排列 p,定义 g_i=\gcd_{j=1}^i\left{p_i\right}f(p) 为 $g_1 阅读全文
posted @ 2022-04-09 13:52 little_pinkpig 阅读(24) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示
more_horiz
keyboard_arrow_up light_mode palette
选择主题
more_horiz
keyboard_arrow_up light_mode palette
选择主题