· Olympiad in Informatics

Codeforces Round #522 (Div. 1, based on Technocup 2019 Elimination Round 3) - Problem-Solving Report

First take the Manhattan distance as the answer, then enumerate the initial directions of the two points, and then just take the minimum.

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

· Olympiad in Informatics

LibreOJ#2353. [NOI2007] Currency Exchange — Solution

First, this problem comes with a hint:

There always exists an optimal trading plan in which every buy operation uses up all the RMB, and every sell operation sells all the gold vouchers.

So we can just consider directly computing the maximum this money reaches as it changes hands again and again. Define the state \(dp[i]\); then we have the transition:

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

· Olympiad in Informatics

LibreOJ#3077: [2019 National Training Team Mutual Test Day 4] Composing Poems Blindfolded — Solution

This problem asks you to implement a Checker that determines whether there are cycles of the same length. The main way to do it is to find all the cycles and tally them in buckets. We can observe some simple properties to make a check first:

  • If there is an edge-biconnected component with \(|E| - |V| \geq \sqrt{|V|}\), then there must be two cycles of the same length. For the concrete proof you can square it, and then find that the square of the difference is greater than the number of vertices. Hand-wavy intuition: by the pigeonhole principle, there will be some edges that form cycles of the same length.

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

· Olympiad in Informatics

BZOJ4833: [Lydsy1704 Monthly Contest] Least Common Multiple of Pell Numbers — Solution

Although it's a standard-trick problem, I decided to write a blog post to reinforce it, so as to fully appreciate the charm of min-max inversion.

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

· Olympiad in Informatics

Codeforces Round #526 (Div. 1) - Problem-Solving Report

Stupid tree DP.

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

· Olympiad in Informatics

LibreOJ#2548: [JSOI2018] Desperate Counterattack — Solution

At first glance this problem doesn't look very doable, because there are so many possible placements. However, when computer science can't solve a problem, it doesn't fuss over the intended solution, only over approximation. So we can enumerate a rotation angle \(\theta\) to determine the final arrangement. After enumerating it, we can directly binary search on the cost, build the edges and solve it as a bipartite graph.

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

· Olympiad in Informatics

Codeforces Round #534 (Div. 1) - Problem-Solving Report

Fill the vertical ones and the horizontal ones separately, top and bottom.

There are 60 queries in total, so we can split them into two batches of 30: the first 30 are used to query the bit just before the highest bit, and the second 30 bits are used to complete our guess of \(a - 1\).

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

· Things

February Summary

This month went a lot better than last month. I also started doing problems and learning new things on a regular schedule; I just wrote a bit too few blog posts. I should write more blog posts in March.

In February I could say I finally got my direction completely sorted out and found my original aspiration again, and I know how to go on from here, too. I hope I can keep up a fairly good state from now on.

That's it.

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

· Olympiad in Informatics

P5169: xtq's XOR Sum — Solution

This one is actually pretty nice. The path you finally get from the XOR is made up of chains and cycles. We can compute the chains and the cycles separately, because the distance from some point on a chain to some point on a cycle can be counted twice, so it has no effect. So we can make one polynomial for the chains and one for the cycles, then do one more FWT_XOR and it's perfect.

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

· Olympiad in Informatics

Codeforces Round #620 (Div. 2) - Problem-Solving Report

A round I did the night before last. I didn’t expect there to be so many gods, and they straight-up separated out a little idiot like me who got stuck on problem D, sigh.

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