随笔分类 -  ACM-思维题

摘要:https://ac.nowcoder.com/acm/contest/5675/C 题意 给出一个树,q次修改,每次修改将第p条边权值修改为w。 回答q+1询问,每次操作可以选择一条链,把这条链上所有边的权值减一,问最少进行多少次操作才能把所有边权全部归零。 题解 考虑每个节点的边进行匹配,如果最 阅读全文
posted @ 2020-09-10 22:34 Artoriax 阅读(211) 评论(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/5673/I 题意 给了两个数组:\(\{a_1, a_2, \dots a_n\}, \{b_1, b_2, \dots b_n\}\) 第i步可以从$a_i$和$b_i$中选择一个数。 求最后选出的数中,不同的数要最多 题解 阅读全文
posted @ 2020-09-08 14:26 Artoriax 阅读(194) 评论(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 1332E Height All the Same Alice has got addicted to a game called Sirtet recently. In Sirtet, player is given an $n \times m$ grid. Initial 阅读全文
posted @ 2020-04-01 14:59 Artoriax 阅读(329) 评论(0) 推荐(0)
摘要:Codeforces 1326E Bombs You are given a permutation, $p_1, p_2, \ldots, p_n$. Imagine that some positions of the permutation contain bombs, such that t 阅读全文
posted @ 2020-03-29 18:30 Artoriax 阅读(233) 评论(0) 推荐(0)
摘要:Codeforces 1323D Present Catherine received an array of integers as a gift for March 8. Eventually she grew bored with it, and she started calculated 阅读全文
posted @ 2020-03-26 21:16 Artoriax 阅读(206) 评论(0) 推荐(0)
摘要:Description You are given an array a consisting of n integers. In one move you can choose any aiai and divide it by 2 rounding down (in other words, i 阅读全文
posted @ 2019-09-03 22:21 Artoriax 阅读(449) 评论(0) 推荐(0)
摘要:Description Heard that eom is a fishing MASTER, you want to acknowledge him as your mentor. As everybody knows, if you want to be a MASTER's apprentic 阅读全文
posted @ 2019-09-03 21:48 Artoriax 阅读(140) 评论(0) 推荐(0)
摘要:题目链接 https://vjudge.net/problem/CodeForces 1132C 题面 Description You have a long fence which consists of $n$ sections. Unfortunately, it is not painted 阅读全文
posted @ 2019-03-08 12:37 Artoriax 阅读(565) 评论(0) 推荐(1)
摘要:题目链接 https://vjudge.net/problem/CodeForces 1121C 题面 Description Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows al 阅读全文
posted @ 2019-03-08 12:26 Artoriax 阅读(638) 评论(0) 推荐(0)
摘要:题目链接 http://acm.csu.edu.cn:20080/csuoj/problemset/problem?pid=2214 题目 Description 有一个1到N的自然数序列1,2,3,...,N 1,N。 我们对它进行M次操作,每次操作将其中连续的一段区间 [Ai,Bi][Ai,Bi 阅读全文
posted @ 2019-02-14 00:29 Artoriax 阅读(180) 评论(0) 推荐(0)