随笔分类 -  ACM-DP

摘要:https://ac.nowcoder.com/acm/contest/5675/J 题意 给出两棵同构的树,问最少修改多少点,让两棵树相同,即根节点相同,非根节点父亲节点的编号相同。 题解 设$dp[u1][u2]$为$tree1$的子树根节点为$u1$,$tree2$的子树根节点为$u2$,子树 阅读全文
posted @ 2020-09-10 22:54 Artoriax 阅读(211) 评论(0) 推荐(0)
摘要:https://ac.nowcoder.com/acm/contest/5674/B 题意 现在有一棵树,你要从1开始跳一遍所有的点并且每条边只能走两次,再回到1,每条边都有一个边权,你走过这条边会先消耗$w_i$点HP,每个点都有一个果子,吃掉这个果子会上升$a_i$点HP,你在任何时候的HP不能 阅读全文
posted @ 2020-09-10 22:19 Artoriax 阅读(176) 评论(0) 推荐(0)
摘要:https://ac.nowcoder.com/acm/contest/5673/E 题意 定义$f(n)$为拆分n为$a_1,a_2 \dots a_m$满足相邻两个数差值不能超过1,且最大值和最小值差值为2的拆分个数,T次询问,每次询问$\sum\limits_^r f(i)$ 题解 拆分肯定由 阅读全文
posted @ 2020-09-08 15:39 Artoriax 阅读(158) 评论(0) 推荐(0)
摘要:https://ac.nowcoder.com/acm/contest/5671/H 题意 求$1 \le A \le B \le N$,满足$S(A)>S(B)\(的\)(A,B)$个数 s是数码和 题解 数位dp,设$f[pos][dif][f1][f2]$为确定了$pos-n$位,差为dif, 阅读全文
posted @ 2020-09-01 15:41 Artoriax 阅读(208) 评论(0) 推荐(0)
摘要:https://ac.nowcoder.com/acm/contest/5670/A 题意 有一个n个点m条边的带权图,你一开始在1号点,你要按顺序完成k个任务,第i个任务是先去a[i]再走 到b[i]。当你走到一个点上的时候,你可以在这个点创建一个传送门。当同时存在两个传送门的时候, 你可以在传送 阅读全文
posted @ 2020-09-01 14:25 Artoriax 阅读(148) 评论(0) 推荐(0)
摘要:https://ac.nowcoder.com/acm/contest/5668/E 题意 给出一个序列,找到两个不重复的匹配,求最小的匹配值,匹配值为相匹配的数绝对值差的和 题解 最小的匹配肯定是相邻数之间的匹配。 次小的匹配可以分解成长度为4的匹配和长度为6的匹配,dp求得次小值即可 #incl 阅读全文
posted @ 2020-08-31 15:23 Artoriax 阅读(152) 评论(0) 推荐(0)
摘要:Codeforces 1312E Array Shrinking You are given an array $a_1, a_2, \dots, a_n$. You can perform the following operation any number of times: Choose a 阅读全文
posted @ 2020-03-26 16:00 Artoriax 阅读(306) 评论(0) 推荐(0)
摘要:题目链接 https://vjudge.net/problem/CodeForces 1132F 题面 Description You are given a string $s$ of length $n$ consisting of lowercase Latin letters. You ma 阅读全文
posted @ 2019-03-08 12:47 Artoriax 阅读(783) 评论(3) 推荐(0)
摘要:题目链接 https://vjudge.net/problem/CodeForces 455A 题面 Description Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. O 阅读全文
posted @ 2019-02-16 17:37 Artoriax 阅读(228) 评论(0) 推荐(0)
摘要:CSU "2034" Column Addition Description A multi digit column addition is a formula on adding two integers written like this: A multi digit column addit 阅读全文
posted @ 2019-02-04 16:19 Artoriax 阅读(250) 评论(0) 推荐(0)