Competitive Programming

IOI 2012

All 6 IOI tasks from 2012, organized as individual solution pages.

6 problem pages
6 editorials
6 C++ solutions
May 21, 2026 most recently updated solution

Problem set

Each entry below goes straight to the public problem page, with the statement, editorial, code, and raw resources kept together.

IOI 2012

Crayfish Scrivener

Implement a text editor with three operations: TypeLetter(c): Append character c to the current text. UndoCommands(u): Undo the last u commands, restoring the text to its state u operations ago. Undo can undo other un...

TeX C++
Open problem page
IOI 2012

Ideal City

A city consists of N unit-square blocks on a grid (connected via shared edges). The distance between two blocks is the shortest path length through adjacent blocks. Compute the sum of pairwise shortest-path distances...

TeX C++
Open problem page
IOI 2012

Jousting Tournament

There are N final positions, one of which will be occupied by the late knight of rank R. The other N-1 positions contain the ranks in array K in their original order. For each round i, the master removes the consecuti...

TeX C++
Open problem page
IOI 2012

Last Supper

N people arrive in order, each preferring a color C[i] (from K possible colors). Chairs are numbered 0 to N-1. The advisor sees the full sequence C[0..N-1] and writes one advice bit per person. The assistant uses thes...

TeX C++
Open problem page
IOI 2012

Odometer

A robot on an R C grid has two odometers: one counting horizontal moves and one counting vertical moves. Given a start and target position (with obstacles), find a path where the horizontal and vertical odometer readi...

TeX C++
Open problem page
IOI 2012

Parrots

Encode a message of N 64 bytes into a multiset of integers in [0,255]. The decoder receives the integers in arbitrary order and must reconstruct the original message exactly.

TeX C++
Open problem page