【杂题乱写】2023-11 #1
2023-11-16
【AGC054C】
Let be the number of j s where is larger than .If we find a is greater than and is larger than k, we can swap the two position.
You can see that if those who contribute to must contribute to so we have proved that if there exists a then there is a place to swap.
Repeat it until there are no proper places that satisfy the condition above. You can see that no avoidable operation appears thus it's the optimal strategy.
We need to count the original sequence next. According to the statements above, we push forward until . So firstly calculate the of the input sequence and Multipy ans with where because we won't change the numbers appears before i and we can start swaping from all the
2023-11-15
【ABC216H】
A Review of LGV Lemma. Enumerate the final positions . Set the inverse pairs(, as defined in the task) in as . Then our final answer is
Finding the answer with trivial bitmask dp is the solution.
【CF1097G】
A Review of Stirling numbers. Remember that the combinatorial significance of 's formula uses different boxes and balls.
This task uses another combinatorial significance when you get the following equation:. See here we need to calculate and this is equal to the method of choosing edge(s) from the subgraph. Thus we can use dp to find it.
DP is nontrivial.Please think it carefully yourself.
【CF1383E】
Problem with strings. What do you think of? Automations of course! Set as the different strings ended at . We extend those distinct strings by 0/1.
Discuss it separately.
To append a 0:If we have or then we can transfer to the nearest 0 after . What if this is the final one of a consecutive zeros? Just find the next zero segment with a larger length and transfer to the matching place.(Hope you can understand what matching places are.)
To append an 1:Just find the earliest 1 appeared in the suffix and finish the transformation.
The solution above force 1 to be the first and the last character. The contradicted ones can be found by calculating the longest prefix 0s and suffix 0s.
2023-11-14
【牛客挑战赛57】
- C
Check your understanding to the description of the problem first! not
so use tree-chain decomposition & fenwick Tree to maintain the contribution from X's child or father.
- D
Let's simplify this problem to a game on a chain of the length of the tree's diameter.Assuming that the first player starts at S,we choose it's first target to be the point T which S&T are about the symmetry of the center point.
Then whatever R become the third visited point,the first player chooses P be the symmetirc point.
Thus our goal is to check whether the symmetic point of the given node is available on the first step.
trick:how to find the center vertex on the diameter? set u,v to be the extreme point of your diameter and exists . The th(nd/rd/st) father of v is our goal.
- E
Let be the mex of the first set and define similarly.
Distributing is easy and we record it as .If we force to be and ,number on allocation plans are trivial function with
Pay attention to the fact that . Get the answer using semi-online convolution
【CF1476F】
it was previously done when preparing NOI2022.RETASTE it.
Two choices for every point i:left/right.Let be the largest prefix covered.If right side is chosen for i then we have
Otherwise we choose the left side, find the smallest such that using binary search and query the largest with trivial data structure.
Time complexity
【CF798E】
We can skillfully solve this problem with 's topsort. To optimize it,let find some other ways to get the final order.
Let me show you another way of getting the topological order. Reverse the former directed graph and DFS from those who aren't visited before.Append a node when returning.Ultimately you'll get a topological sequence of the original nodes.
If you are worrying about choosing starting point abitarily would cause a bad result,take tarjan for example.
2023-11-13
【ARC156D】怎么忘了生成函数来着。其实你只需要关注系数模 2 余 1 的指数的 xor。一个平方中交叉项会被搞掉。然后变成了 选 log K 个 每个 乘 。记录进位
【ARC148E】想到一种一种数字往里插入就简单多了。根据插入这种结构,那么肯定是按照 排序。等值肯定较大的先插入。不断更新能插入的位置,遇到大于 的需要隔板诶。
【ecfinal2019】首先发现质数处点值就是直接除。接下来过了很久发现其实就是 。从小到大求一遍,于是想求 的时候通过 dp 求出来(这个 dp 只关心 n 因数处点值),或者说 表示用了 个数,乘积是 (这些数字都大于 1) 转移枚举倍数。好像是两个 log 的。
这个转移好像还有点东西,因为 的 还未知所以只能枚举小的一部分。
2023-11-07
【CF633H】忘了区间查询题目可以使用莫队
【牛客挑战赛57】
- B
应该先想到矩形里面最大的元素是多少。然后能不能找到两个数异或和比他大。注意到奇数不满足 而是要进一大堆位,于是发现这个奇数可以是 。
再想想如果 和 分列两行首尾怎么办,其实这就是补码的问题。找每行 C 位就行了。
2023-11-08
【CF1406D】鉴定为复健失败了,好耶!
2023-11-09
【ARC167C】
大豆托尼老师好像也不会做这个题,所以我不会做也是理所应当的。
考虑计算每种边权的边的出现次数。变成统计小于等于 的边的出现次数。
变成了 的边往图里面加,统计有多少边在不形成环的情况下加多少边
那么排序之后直接相邻的能加就加肯定是不劣的,所以直接统计两个元素之间位置差 的方案数就行了。最后表达式就写成
两个阶乘表示相对顺序,后面是组合数是把 个元素捆起来,剩下的元素选位置, 表示选择把这一捆是这 个数位置上的第几个(不能是最后一个)
2023-11-10
【ARC156C】 主要思想是两两配对一定不差。所以找到重心配个对就行了。
【ARC136D】 莫名其妙题。高位前缀和是先对若干维完整求和,再对某一维求和就行了。
好像还有两个 ARC 水题,atproblems 评分也不高。
做了一个 ARC127D 应该是原来做过的,但是好像理解的有点问题。后来证明了一下复杂度确实是没啥问题。
【ARC135D】
把棋盘黑白染色,并把黑色的格子上的元素取反,同时把操作中的全部加法变成一个对角线加一个对角线减。已经完全忘掉黑白染色了。有点遗憾。
鉴于如果行列元素总和一样的棋盘都能通过该操作来实现转换,所以把问题变成对列的总和的操作:如果有一行一列乘积总和大于 那么在交点行的和或者列的和调整到 ;否则如果两行乘积小于 可以一个加一个减,把绝对值较小的搞成 ;对列进行一样的操作。
我们一共进行了 (行和绝对值之和,列和绝对值之和)次操作。
2023-11-12
【ARC150D】期望线性性,计算每个点被点了多少下。然后枚举链后缀长度,表示这一段里面这个点是第一个点的,这部分等比数列求和,但是后缀长度是 的时候只能点一次。
可能需要想一下为什么不是
【ARC151E】这题还是比较简单的。求出来最长公共子串(我个人的想法是对一个建 SAM 然后另一个在上面走,计算每个后缀在 SAM 上能走多少这样。
鉴于不能把 X 删空,所以 LCS = 0 的时候还有点工作要做,不难发现你这时候保留一个数去 a 里面找子串肯定是最好的,于是统计得到单个 1~ 9 字符最少进行多少次操作。
【ARC151C】子局面 SG 的 xor。完整的线段有四种,两边都没点,一边没点,两边有点但是颜色不同,都有点颜色一样。转移式子显然。果断打表。
【ARC152D】多画图。这题我切了。
【ARC153D】 表示第 位有 个数字进位,前 位的最小值。注意到这 个数字一定是 位最大的 个。枚举 的第 位就行了。这里的后效性我想了一下才弄明白
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律