After reading the solution, I found this is just a stupid problem.
Consider treating each column as a number. We find that if we ignore the column operations, these numbers still satisfy the arithmetic-progression condition, so we only need to brute-force the first column and can then just keep adding the common difference. If we take the column operations into account, then we just brute-force it hard, and the time complexity is \(O(n + m)\).
Continue reading →Chinese original · English translation by Claude Opus 5.5
Today I got crushed by gods from every corner, and went gg right on cue.
In the exam room I derived a DP with aftereffects and thought it was Gaussian elimination, then I saw the constraints and it was GG. The main thing in this problem is converting some stuff into something else.
Continue reading →Chinese original · English translation by Claude Opus 5.5
Let's first think about the ordinary brute-force search: enumerate the color pressed each time, then check and keep updating. Consider optimizing this process with IDA*. First, the heuristic function is just the number of remaining colors, because at least these colors have to be updated before the final state can possibly be reached. Then just pay attention to the optimization of controlling how many times BFS is run to find connected components. A really nice problem.
Continue reading →Chinese original · English translation by Claude Opus 5.5
For a function \(f(x)\), if it is differentiable everywhere on its domain, then it can be written as a polynomial function (that is, the Taylor expansion of this function). In general, we have:
Dynamic centroid decomposition is really not friendly.
Let's first consider the static \(O(nq)\) approach. We can pick any root, process two arrays in \(O(n)\) to record the weight sum inside each subtree and the weight sum outside it, and then do another \(O(n)\) pass to check whether the answer is minimal.
Actually, from here we can find a relation: if a node's child is better than its parent, the following holds:
Continue reading →Chinese original · English translation by Claude Opus 5.5