AGC 26 F Manju Game

$\DeclareMathOperator{\sw}{sw}$ $\DeclareMathOperator{\sb}{sb}$ $\DeclareMathOperator{\dp}{dp}$ 用 $\sw[i]$ 表示前 $i$ 个盒子中全部白盒子的权值之和。 用 $\sb[i]$ 表示前 $i$ 个盒子中全部黑盒子的权值之和。app

对于偶数 $i$,用 $\dp[i]$ 表示此白盒子以前的全部盒子是否存在合法划分。this

转移方程

$\dp[i] = \mathsf{true} \iff$ 存在偶数 $j < i$ 知足 $\dp[j] = \mathsf{true}$ 且 $\sb[i-1] - \sb[j] - (\sw[i-1] - \sw[j]) \ge X$ 。url

注意到,$ \sb[i-1] - \sb[j] - (\sw[i-1] - \sw[j]) \ge X $ 即 $ (\sb[i-1] - \sw[i-1]) - (\sb[j] - \sw[j]) $ 。spa

思路示意图

题解上所说的.net

Let $W_1, \dots , W_k$ be the white boxes that appear in this tree, from left to right. The first player will take all these boxes, no matter what the second player does. These $k$ boxes split the sequence of boxes into $k + 1$ parts. For one of these parts, the first player takes all black boxes and the second player takes all white boxes. For all other parts, the first player takes all white boxes and the second player takes all black boxes. The choice of the "one part" depends on the second player’s strategy.code

能够这样理解:游戏

先手玩家能够事先从左到右任选 $k$ 个白盒子(即上图中的圆形)这些白盒子将余下的盒子分红 $k+1$ 段(即上图中的矩形,当总共有奇数个盒子时,最后一段多是空的)。不管后手玩家如何应对,先手玩家总能够在最后一个阶段取走这 $k+1$ 段中某一段里的全部黑色盒子而结束游戏,而让先手玩家最后取走哪一段里的全部黑盒子彻底由后手玩家肯定。ci

有一种特殊状况须要注意:当 $n$ 为偶数时,若先手玩家在某一步拿走了最后一个白盒子,那么先手玩家的「最后一个阶段」只能是「取走最后一个白盒子以后的空段里的黑盒子」而不能是「取走最后一个白盒子以前的某一段里的全部黑盒子」,在这种状况下,先手玩家在最后一个阶段的行为是由先手玩家本身决定的,而不是由后手玩家决定的。事实上,若是先手玩家取了最后一个白盒子,那么他必然取走了所有白盒子然后手玩家取走了所有黑盒子。get

因此最好是对 $n$ 为偶数的状况单独处理,这种状况下先手的策略是:取所有黑盒子或所有白盒子。it

相关文章
相关标签/搜索