版本比较
0119
正文
增加 7 行删除 12 行
1123445667891091112111213141516171813What does it mean?何意味。被【数据删除】翻译软件搞成英文,然后重写。
[A](http://oi.nks.edu.cn:19360/zh/Problem/Details?cid=3440&tid=A)考虑什么数可以被 4 和 7 拼出来,参考小凯的疑惑,当一个数 $x \ge 4 \times 7 -4-7+1$ 时可以被覆盖,那么考虑 17 之内的不符合的数和符合的数全部打表打出来,然后对于就可以 dp 了,值域上直接 dp 可以获得 60 pts,但是发现 $n$ 极小,遂改为 $f_i$ 表示当前到达第 $i$ 个位置的时候可以获得的矿石最多的数量,然后向前枚举 $17$ 个数,若有数与其位置之差(绝对值)为 17 之内满足条件的可以被 4/7 拼出来的。然后对于所有位置数差大于 18 的数,就记录 dp 前缀最大值然后转移做完了。
[A] (http://oi.nks.edu.cn:19360/zh/Problem/Details?cid=3440&tid=A) Consider what numbers must be made up, since $ x\ge 4\times 7-4-7+1$ can be made up, referring to Xiao Kai's doubts, then play all the numbers that can be made up within table 17, and then $f_i$ means that the current $i$ mining point is reached, and then the maximum value is obtained, Since you need to look for the first 17 numbers and consider whether you can transfer them, you only need to transfer them if you meet the subscript of $j < i-17$, and then record the maximum value of the prefix. [B](http://oi.nks.edu.cn:19360/zh/Problem/Details?cid=3440&tid=B)这道题是一道很板的树形 dp,因为每个点都只会走一次,答案 $+n$ 即可,考虑 $f_{x,j}$ 表示以 $x$ 为根的子树中一共有 $j$ 个机器人停留在内部走完所有树边的最小代价,情况1,需要,$f_{x,j}=f_{x,j}+f_{y,0}+2*w$,表示走到子树内部之后不能留下机器人而必须走回来。情况 2,$f_{x,j}=\min _{1\le k \le j}f_{x,j-k}+f_{y,k}+k\times w$。注意整个过程枚举 $k$ 需要倒序,由于是树上背包,那么通常记录一个子节点顺序 $f_{x,son,j}$,考虑滚掉 $f_{x,son,j}$ 中 $son$ 这一维,简单的,在上一步的基础上做出下一步,但是同时更新于上一步,那么也就需要倒序枚举然后保证没有后效性。
[B] (http://oi.nks.edu.cn:19360/zh/Problem/Details?cid=3440&tid=B) A tree dp, there is $f_{x,j}$ representing $x$ There are $j$ robots left inside in the subtree of the root node, case 1, return after walking the subtree, i.e. $f_{x,j}=f_{x,j}+f_{y,0}+2\times w$, Noting why we are shifting ourselves, because there is usually a child order when backpacking in a tree, then we consider optimizing on $f_{x,son,j}$, and after the optimization is completed, $son$ is pressed off by one dimension, but the update must be reversed. Case 2, $f_{x,j}=\min _{1 \le k \le j}f_{x,j-k}+f_{y,k}+k \times w$, and done.[C](http://oi.nks.edu.cn:19360/zh/Problem/Details?cid=3440&tid=C)分数规划加树形 dp,分数规划很容易直接二分然后套路,考虑 $\frac{\sum p_i}{\sum s_i} \ge mid$,那么也就是 $\sum p_i \ge mid \times \sum s_i$,那么移项 $\sum p_i-mid \times s_i \ge 0$,很容易发现每一个数的贡献是 $p_i-mid \times s_i$,注意到题目中的 $k$ 个人的限制并且还有推荐关系,那么就很可能是树形 dp,直接做一个树形 dp,$f_{x,j}$ 表示在以 $x$ 为根节点的子树中选择 $j$ 个人的最大收益,那么显然 $f_{x,j}= \max _{0 \le k \le j}f_{x,j-k}+f_{y,k}$,但是这样是 $\mathcal{O}(n^2m)$ 的,多一只 $\log$ 肯定过不去,NKOJ 老年机发力,$\mathcal{O}(n^2 \log n)$ 卡 2s 过不去,然后考虑一种树形 dp 的常用技巧,就是把树排成一个 dfn 序,然后在上面 dp,也就是如果当且这个节点选择的话就会在 dfn 序上 $f_{i-1,j-1}+val_{now_i}$,然后再考虑不选择的情况,然后做完了。
[D](http://oi.nks.edu.cn:19360/zh/Problem/Details?cid=3440&tid=D)考虑来回走的人,走完的必然是一个区间,然后有 $n \le 100$,容易的,就设出 $f_{i,j,0/1}$ 表示当前区间 $[i,j]$ 已经走完,最终停留在左节点/右节点,考虑一个决策会对后面所有的收获的钱产生影响,费用提前计算一下就好。
[C] (http://oi.nks.edu.cn:19360/zh/Problem/Details?cid=3440&tid=C) Score planning, not finished with ironing. Fraction planning thinks of dichotomies, with $\frac{\sum p_i}{\sum s_i} \ge mid$ if and only if $\sum p_i \ge mid \times \sum s_i$, obvious $\sum {p_i-mid \times s_i} \ge 0$. Then I found that selecting $k$ individuals, as well as dependencies, the tree dp set was done, but the old age of this problem NKOJ will get stuck with the direct $\mathcal{O}(n^2m)$ tree dp, and then can only be transferred through $siz$ with $dfn$ subtree tricks.[E](http://oi.nks.edu.cn:19360/zh/Problem/Details?cid=3440&tid=E)考虑一次走下一个节点实际上实在关于对角线 $i+j=n+1$ 对称的两个点的代价总和,然后就据此为边权连接边,然后跑最短路计数,最后在对角线上取最优和计数。~~$n \le 50$ 是不是可以乱搞啊,说不定 $2 \times 2^{25}$ 的折半有可能【数据删除】过去呢。~~
[D] (http://oi.nks.edu.cn:19360/zh/Problem/Details?cid=3440&tid=D) This is even more heavyweight, ~~ consider $n \le 100$, think of the range dp~~, because you need to run back and forth, then compare with Lao Zhang's street lamp, then $f_{i,j,0/1}$ means that the current $[i,j]$ section of the number, stay at the left end or the right end, Note that some points can be chosen not to be sent, and then it is said that the cost is calculated in advance, because choosing to send a customer will contribute time to all the customers who will be sent later.
[E] (http://oi.nks.edu.cn:19360/zh/Problem/Details?cid=3440&tid=E) Considering that each step taken is equivalent to the corresponding point in the case of symmetry, that is, after $i, j$ goes, it is equivalent to the sum of the cost of the point after the symmetry of the diagonal line of $i+j=n+1$ and the current point.
[F] (http://oi.nks.edu.cn:19360/zh/Problem/Details?cid=3440&tid=F) This question must dig a hole, ~~ because I didn't understand it in class~~, consider $f_{n,m,k}$ to indicate that the current is in the present[F](http://oi.nks.edu.cn:19360/zh/Problem/Details?cid=3440&tid=F)一个很【数据删除】的题目,班上有个大手子把 dp 打表出来看然后发现压掉一维过了,膜拜。考虑 $f_{i,j,k}$ 表示当前所在的行有 $i$ 个未被填,另外一行有 $j$ 个未被填,然后在当前行的第 $k$ 个位置上(是相对位置,考虑一个节点被连了之后就等于删除),然后就有 $f_{i,j,k}=f_{i-1,j,k}+f_{i-1,j,k-1}+\sum_k f_{j,i-1,k}$,其含义在与向左连,向右连,向另一行连,然后 $g_{i,j}=\sum_k f_{j,i-1,k}$,最后 $g$ 成功占领 $f$ 数组,然后就是 $g_{i,j}=2 \times g_{i-1,j}+n\times g_{j,i-1}$,然后做完了。