思路讲解

注意到,根据题设条件,树必须为严格的“Y”||”1”。
AC代码
1 | // Problem: F. Wildflower F. 野花 |
心路历程(WA,TLE,MLE……)
注意,写两种dfs记得要清空vis数组。

注意到,根据题设条件,树必须为严格的“Y”||”1”。
1 | // Problem: F. Wildflower F. 野花 |
注意,写两种dfs记得要清空vis数组。
首先,遇到数论问题不要怕,我们人类其实对许多数论问题其实都束手无策,就靠计算机枚举。
那么,通过素因数分解,不难发现,我们可以把问题转化为这个。
💡 Note: 给你一个序列,比如说1,2,2,3,5,你要将这个序列删空,你一次可以选择任意多的数,只要这些数的乘积小于K。要求你找到一个方式,使用最少删除次数,告诉我这个次数。
那么其实经过素因数分解得出的序列是不会有 1 的。

把xrem除掉,再乘上yrem,就相等了。
记忆化搜索的时间复杂度那基本上等于 状态数×入口数量,这里的状态数量其实就是因数的数量,入口数量也是因数数量,所以最坏情况下时间复杂度为 O(n32)。

这个super composite number 就是因数数量特别多的数,比比他小的所有数的因数都多,那么这样的数大概因数数量也就是 3n 。
A highly composite number is a positive integer that has more divisors than all smaller positive integers. If d(n) denotes the number of divisors of a positive integer n, then a positive integer N is highly composite if d(N) > d(n) for all n < N. For example, 6 is highly composite because d(6)=4, and for n=1,2,3,4,5, you get d(n)=1,2,2,3,2, respectively, which are all less than 4.
1 | ll dfs(ll val){ |
那么问题的关键就在于减少入口,注意到只有因数是合法的。
https://codeforces.com/contest/2114/submission/323597405
1 | // Problem: F. Small Operations |
是比较简单的树上dp问题,记录一下。
1 | void dfs(ll node,ll x0,ll x1,ll cnt){ |
https://codeforces.com/contest/2114/submission/323228554
1 | // Problem: E. Kirei Attacks the Estate |
感觉每次选择都可能有后效性怎么办?
1 | // 碰到b,a c,a operate 在最近的位置 |
仔细一想那,这道题目也没有那么复杂其实,其实只有b,c是需要考虑是否操作的。
只考虑那么一种情况的话,其实就看后面有没有c,a,而且b的前面c的数量啦。
https://www.cnblogs.com/fwdzh/p/18909502
这个题解告诉我们,我们是不可能在线处理的,这个难度是比较大的,但是我前面一直在想这个(QAQ)。
https://codeforces.com/contest/2111/submission/322930903
1 | // Problem: E. Changing the String |
那么我们发现,匹配应该是这样匹配,而不是用最大的匹配最小的。
1 | if(*g[idx2].begin()<*g[idx3].rbegin()){ |
这道D题确实不算太难,我赛时应该也是可以写出来的。
采用类似于下图的构造方式即可

https://codeforces.com/contest/2111/submission/322856069
1 | // Problem: D. Creating a Schedule D. 创建时间表 |