· Olympiad in Informatics

[Fortuna OJ] Aug 5th - Group A Problem-Solving Report

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

· Olympiad in Informatics

[Fortuna OJ] Aug 4th - Group A Problem-Solving Report

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

· Olympiad in Informatics

[Fortuna OJ] Aug 2nd - Group A Problem-Solving Report / National Training Team Mutual Test 2012 [Li Chao]

On JZOJ this problem has a 10s time limit, so it got AC.

Continue reading →Chinese original · English translation by Claude Opus 5.5

· Olympiad in Informatics

Binomial Inversion

The main content of binomial inversion is:

\[f_n = \sum_{i = 0}^n (-1)^i {n \choose i} g_i \longleftrightarrow g_n = \sum_{i = 0}^n (-1)^i {n \choose i} f_i\]

This inversion formula is really beautiful: in this form, the two sides are symmetric. Of course, it can also be written as:

Continue reading →Chinese original · English translation by Claude Opus 5.5

· Olympiad in Informatics

[Fortuna OJ] Aug 1st - Group A Problem-Solving Report

Truly subtle, layer upon layer.

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

· Olympiad in Informatics

Inversion Basics

If we know that \(\{ f_n \}, \{ g_n \}\) satisfy this relation:

\[f_n = \sum_{i = 0}^n a_{ni} g_i\]

then we can use the known values of \(f_0, f_1, \dots, f_n\) to compute \(g_n\):

Continue reading →Chinese original · English translation by Claude Opus 5.5

· Olympiad in Informatics

Taylor Expansion

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:

\[f(x) = \sum_{n = 0}^{\infty} \frac{f^{(n)}(x_0)}{n!}(x - x_0)^n\]

When \(x_0 = 0\), this expression is also called the Maclaurin series.

Continue reading →Chinese original · English translation by Claude Opus 5.5

· Olympiad in Informatics

P3317: [SDOI2014] Rebuild — Solution

Normally, with the Matrix-Tree theorem, what we're really computing is this:

\[\sum_T \prod_{e \in T} p_e, \forall p_e = 1\]

What we're computing is really just the case where all probabilities are \(0/1\). Now we need to compute:

Continue reading →Chinese original · English translation by Claude Opus 5.5

· Olympiad in Informatics

P3345: [ZJOI2015] Gensokyo Strategy Game — Solution

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

· Olympiad in Informatics

[Fortuna OJ] Jul 11th - Group B Problem-Solving Report

This problem really tests your thinking. Here I'll present the DP approach.

Let's consider DP. The equation can roughly be written as:

\[dp[i] = max\{ dp[j], j \in S_i \} + 1\]

Continue reading →Chinese original · English translation by Claude Opus 5.5