AtCoder Regular Contest 098 - Problem-Solving Report
Just mess around a bit with prefixes and suffixes and you're done.
Continue reading →Chinese original · English translation by Claude Opus 5.5
Just mess around a bit with prefixes and suffixes and you're done.
Continue reading →Chinese original · English translation by Claude Opus 5.5
This problem has so many fucking details.
First, seeing that the SCC size is less than \(100\), you can tell it's DAG DP + Tarjan + Gaussian elimination; that's fairly obvious. However, it's a real pain to implement. When we do the DP on the reversed graph, after taking a vertex out of the queue, we first run Gaussian elimination in one go, putting the ones inside the cycle and the ones between SCCs (that is, the previously computed \(dp[u]\)) together into the system of equations and eliminating. See the code for the details; honestly, I want to puke.
Continue reading →Chinese original · English translation by Claude Opus 5.5
This problem is so hard to wrap my head around. Let me think.
First, we need to turn this problem into a binary problem: we can enumerate the final color and then compute each case separately. Say the final color is white and every other color is black. Once it's converted into this problem, we can think about the transitions.
Continue reading →Chinese original · English translation by Claude Opus 5.5
As a partial order problem this one is quite interesting; it was my first time running into “2D partial order”.
First consider the partial order condition. Let the circle's center be at \((a, b)\), and suppose we have a point \((x, y)\). If this point is covered:
\[(x - a)^2 + (y - b)^2 \leq a^2 + b^2\]
Continue reading →Chinese original · English translation by Claude Opus 5.5
Since I grabbed this problem from yyb's blog, I knew it could be done with a segment tree. After thinking about it roughly, my initial idea was to use a segment tree to maintain the longest subsequence length for different heights(?). This actually works: when reading in the heights, first stuff each one into that node's dynamically allocated segment tree, and then the children's trees can be merged. When merging the children, maintain the longest subsequence length obtainable when it is at least \(x\), so we can do it with differences (of course, you can also do a range add with permanent lazy tags): add a one starting from position \(w_u\), and then delete the previous \(1\).
Continue reading →Chinese original · English translation by Claude Opus 5.5
After compressing, count how many \(01\) pairs there are, then just multiply by the smaller cost and add the cost of one flip.
Continue reading →Chinese original · English translation by Claude Opus 5.5
When I first started thinking about it, I thought I could directly set up \(dp[u][0/1]\) to indicate whether the one chance to make a judgment had already been used up. The intended solution is actually pretty close to this; it just uses a more formulaic approach.
Continue reading →Chinese original · English translation by Claude Opus 5.5
First, for \(d = 1\), the answer is just \(k^n\).
For \(d = 2\), it turns out we can actually just multiply generating functions directly: \(A(x) = \sum_{i = 0}^\infty \frac{1}{i!} x^i [2 | i]\), and then the answer is \(A^k(x)[x^n]\). We notice we can get around the parity condition, so \(A(x) = \frac{e^x + e^{-x}}{2}\), and then we try a binomial expansion:
Continue reading →Chinese original · English translation by Claude Opus 5.5
First, notice that the two ends don't matter, so we can directly do a linear DP over segments. Thinking about the brute force the normal way, we find that we have to enumerate the color every time, which is a big hassle. But we can find an especially nice property: the color of each segment is determined by the last element of that segment, because, as we realize, when some other color is chosen, we could perfectly well adjust this segment's right endpoint so that the next segment is no worse.
Continue reading →Chinese original · English translation by Claude Opus 5.5
Obviously we just build a SAM on the reversed string and run a DP on the Link tree. However, the data is huge, so we can’t brute-force each one directly, so we can just wrap it with a virtual tree.
Continue reading →Chinese original · English translation by Claude Opus 5.5