· Things

Mistake Collection

Given \(2\sin^2 A + \sin^2 B = 2 \sin^2 C\), find the minimum value of \(\frac{1}{\tan A}+\frac{1}{\tan B}+\frac{1}{\tan C}\).

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

· Things

May Summary

May is over.

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

· Olympiad in Informatics

Linear Basis Study Notes

A linear basis should count as something within the scope of linear algebra. In OI, linear bases are used to solve problems involving bitwise operations or vector representation.

I suggest readers come back to this article after learning about vectors in high school math; I believe that will help with understanding linear bases.

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

· Olympiad in Informatics

P3313: [SDOI2014] Travel — Solution

You could consider building a segment tree for every color to maintain things, but that would blow up, so we use a segment tree with dynamically created nodes and it passes. Maintain the nodes of different colors separately, then just follow the standard trick of heavy-light decomposition.

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

· Olympiad in Informatics

P4899: [IOI2018] werewolf — Solution

This problem is a textbook problem for the Kruskal reconstruction tree. Let's first consider the human-form state starting from \(s\): we need to find a vertex whose weight is less than \(L\), which is equivalent to using binary lifting on the Kruskal reconstruction tree to find the last vertex less than \(L\). We denote the Kruskal tree that fits the human-form rule as Tl, and it is built by setting the weight of every edge in the original graph to the maximum of its endpoints, then building the reconstruction tree the way you build a minimum spanning tree; the Kruskal reconstruction tree that fits the wolf-form rule is denoted Tu, and it is built by taking the minimum of the endpoint indices as the edge weight, then building it the way you build a maximum spanning tree. After that, we just take the intersection in a persistent segment tree: if there is an intersection, the query result is a nonzero number, and we just output \(1\); if there is no intersection, the query result is \(0\), and we output \(0\).

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

· Olympiad in Informatics

Chairman Tree Summary

The chairman tree is a really interesting data structure. Its full name is actually “persistent segment tree”, and as for why it's called the “chairman tree”, it's because:

Because the initials of its inventor Huang Jiatai's name are the same as those of Hu Jintao (H.J.T.), former General Secretary of the Central Committee of the Communist Party of China and President of China, this data structure can also be called the General Secretary tree or the chairman tree.

From Wikipedia.org

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

· Olympiad in Informatics

Kruskal Reconstruction Tree

The Kruskal reconstruction tree is a kind of spanning tree of a graph, mainly used to solve a class of problems with restrictions on the edge weights along paths. The Kruskal reconstruction tree has the property of being monotonic in depth, so it can easily handle restrictions on the range of edge weights.

The Kruskal reconstruction tree is built in a way very similar to how Kruskal's algorithm builds a minimum spanning tree, but the structure is different: the Kruskal reconstruction tree turns edge weights into node weights, and the node weights get smaller with depth. Suppose we have a graph like this:

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

· Olympiad in Informatics

P3980: [NOI2008] Volunteer Recruitment — Solution

We can picture the whole working process as a chain in a flow network: day \(i\) connects to day \(i+1\) with capacity \(INF - A_i\) and cost \(0\); day \(n+1\) connects to the sink with capacity \(INF\) and cost \(0\); the source connects to node \(1\) with capacity \(INF\) and cost \(0\).

For each group of volunteers \((s_i, t_i, c_i)\), consider adding the edge \((s_i, t_i + 1, INF, c_i)\). This means the whole workflow can draw flow from extra pipes, bringing the maximum flow up to \(INF\).

So the minimum cost we get is certainly obtained under the condition that the maximum flow is \(INF\), and that is the answer.

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

· Olympiad in Informatics

P2604: [ZJOI2010] Network Expansion — Solution

A total freebie.

Consider building a graph from the given data with every cost set to 0. After running min-cost flow to get the max flow and printing that answer, add, on top of the existing edges, an edge with the same direction, infinite capacity and cost \(w_i\); finally, create a new vertex connected to vertex \(n\) with capacity \(k\), and that's it.

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

· Things

April Summary

This month my OI level improved a lot: I learned some tech and also did a lot of Codeforces contests. These contests broadened the range of my thinking, and also made me realize the shortcomings in my thinking. Balanced-BST-related stuff, plus things like Möbius inversion, and I also did lots of network flow and DP problems. All told, this month I wrote 140-odd problems across various OJs (mostly easy problems).

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