I kept having this feeling that I'd done it before in Group A at Jizhong, and it turned out I really had; I just didn't know back then that this thing was called DP of DP.
Continue reading →Chinese original · English translation by Claude Opus 5.5
If we just do brute force, this line of thinking only goes so far. Let's think about it a different way. Since the final answer requires shortest paths over \(\Theta(k^2)\) pairs, we try to shrink this scale, solve only the global answer for a small scale (not computing all the shortest paths), and then after solving it several times we can get the global answer for the full scale.
Continue reading →Chinese original · English translation by Claude Opus 5.5
Computational geometry problems you run into in contests are usually not hard, but if you run into one without having learned it, you just score zero. To avoid that, I decided to properly learn some computational geometry.
Result: I learned it all and still scored zero.
Continue reading →Chinese original · English translation by Claude Opus 5.5
Lately I've been in a really confused state (though it seems my state has been poor ever since the pandemic started). I keep crashing and burning in official contests, but in the usual training contests I sometimes get small gains and a little confidence, and I've kept up my pace of grinding problems (and ground through a lot of some easy problems too), and my Codeforces rating is also moving in the direction I hoped for. These changes are what make me fairly happy in this boring life of training on my own, yet sometimes I also lose my way, can't figure out where I stand, or end up feeling lost.
Continue reading →Chinese original · English translation by Claude Opus 5.5
The best-quality problem in this set (though it is rather similar to a certain BZOJ problem).
We first consider adding all the virus strings into an AC automaton, and then consider a DP transition: let \(dp[i][j]\) be the number of ways in which the current \(i\)-th character is matched at automaton node \(j\). We notice that the data range is very small, so this can actually be optimized with matrices. After building the AC automaton, we compute three matrices for \(a_i = 0, 1, -1\). Once those are computed, just maintain them with a segment tree. (The complexity is sky-high)
Continue reading →Chinese original · English translation by Claude Opus 5.5
This problem is pretty godlike. The main idea is to count triples \((p_1, p_2, p_3)\) such that \(G(S(p_1, p_2)) = G(S(p_2, p_3)) = G(S(p_1, p_3)) = x\). First, consider those with \(G(S(p_1, p_2)) = x\), the pairs \((p_1, p_2)\). Suppose we can find all of these paths, and compute the in-degrees and out-degrees of the directed graph that contains only the directed edges \(S(p_1, p_2)\). If we can compute this kind of thing, we find that the rule of product directly gives the invalid triples (the valid triples can't be handled this way, because you'd also have to compute the stuff for \((p_1, p_3)\) to handle them). If we can get these in- and out-degrees done within the time limit, we then just compute that rule-of-product part in \(\Theta(n)\). For the in- and out-degrees, we can just throw centroid decomposition at it.
Continue reading →Chinese original · English translation by Claude Opus 5.5
At first glance this is hard to do directly. Let's start working from that string of length \(m\), and we find that each \(01\) corresponds to an inequality condition:
Continue reading →Chinese original · English translation by Claude Opus 5.5
Basically, we need to find a subsequence whose length is always the longest across all the changes. We can consider divide and conquer, discussing the left/right positions of the changing points, and then just maintain things with a Fenwick tree.
Continue reading →Chinese original · English translation by Claude Opus 5.5