· Olympiad in Informatics

[SDOI2016] Game — Solution

Clearly we need heavy-light decomposition.

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

· Olympiad in Informatics

[APIO2012] Dispatching — Solution

Mergeable heap approach: build max-heaps from the top up, then pop the top of the heap until the sum of the whole heap is less than m. (Property: a parent node will never choose a ninja its subtree does not contain.)

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

· Olympiad in Informatics

Revival

Hehe, I don't have to retire after all.

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

· Things

Written Before Final Exams and Retirement

···Second, strictly set admission standards: building on the current basis, universities will further lower the bonus points granted to independent-admission candidates. Third, strictly control enrollment scale: universities will moderately cut admission places relative to the previous year's intake.

Life is really so hard.

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

· Things

Regular Classes, Man, I'm Slacking Off Hard

After two months of OI, I feel like my whole IQ has gone back to average. Since coming back to Fuzhong, regular classes feel a lot easier than nasty OI stuff like virtual trees. I read some books and caught up on some of the basic knowledge, but not having done any exercises still cost me a lot.

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

· Olympiad in Informatics

P3773: [CTSC2017] Gift — Solution

There is an “obvious” theorem: if \(n\&k==k\), then \(C^k_n\) is odd. The specific hand-wavy proof: litble's proof. So, straight to the code.

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

· Olympiad in Informatics

The Code Style of Yours Truly

  1. Braces go on a new line (at least in C-family languages; in JavaScript, whatever, but I've never seen anyone use JavaScript in competitions)
  2. Use the variable names from the problem statement whenever possible.
  3. Temporary variables (loop variables, say) can be named with a single letter or a two-letter abbreviation.
  4. Global variables and fields with a long lifecycle should be in lowerCamelCase whenever possible.
  5. Functions and function variables are named in lowerCamelCase.
  6. Constructors that assign values and initialization functions get done in one line (for example initializing an edge, or initializing a disjoint-set union)
  7. Use #define less, use const more.
  8. Inside loops or conditional statements, squash lines together with commas (not too long).
  9. Use a modern editor for automatic formatting (strongly recommend VSCode, say goodbye to the F**K debugging method).

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

· Olympiad in Informatics

Now, I Have Entered Semi-Retirement

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

· Olympiad in Informatics

P1069: Cell Division — Solution

The problem is roughly this: given the numbers \(N\), \(m_1\), \(m_2\), \(S_{i[1\dots N]}\), find the smallest \(t\) such that some \(S_i^t \; mod\; m_1^{m_2}\).

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

· Olympiad in Informatics

P2501: [HAOI2006] Number Sequence — Solution

This problem is really quite nasty.

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