🚀 Alguni Start learning

🏁 Competitive programming for kids

Sorting and searching, greedy algorithms, dynamic programming, graphs, shortest paths, spanning trees, flows, number theory, game theory and the fast Fourier transform — the contest toolkit, at a size a child can hold.

Start the Contest track

How this track is kept honest

Every algorithm here exists to avoid an obvious slow one, so every answer is re-checked by brute force: every subarray, every subset, every permutation, every spanning tree, every ordering of a game. Nothing imports a library that does the lesson for you — heapq and friends arrive only once the thing they replace has been built by hand.

Best after the Python track, and the natural next step from it.

How it starts

You send in a program. A machine runs it on secret data and gives it about one second. Correct but slow scores exactly the same as wrong. So every problem here has two answers: the one that works, and the one that works in time.

The full Contest syllabus

25 units and 101 lessons, in the order they are played. Each unit has a page of its own with every explanation in it, the code samples and what they print, and a few questions to try.

Unit 1: Beat the Clock

Right is not enough — it has to be fast

  1. One Second, That Is All
  2. Naming the Shape
  3. The Limits Tell You the Plan
  4. The Same Answer, Three Speeds

Unit 2: Try Everything

When brute force is the right answer

  1. Every Subset
  2. Every Order
  3. Stop Early
  4. Eight Queens

Unit 3: Bits

A whole set inside one number

  1. Numbers Are Rows of Switches
  2. And, Or, Xor, Shift
  3. A Set Inside One Number
  4. The Number That Came Alone

Unit 4: Sort, Sweep, Grab

What sorting buys you

  1. Sort First, Think Second
  2. Two Pointers
  3. Grab the Best Thing Now
  4. Fitting In the Most Events

Unit 5: Cut It In Half

Binary search, and searching the answer itself

  1. Guess the Number
  2. The First One That Fits
  3. Search the Answer Itself
  4. Meet in the Middle

Unit 6: Questions About Ranges

Answer a million questions about a million numbers

  1. Prefix Sums
  2. When the Numbers Change
  3. The Smallest in a Range
  4. Choosing the Right Box

Unit 7: Remember the Answer

Dynamic programming, the way contests use it

  1. State, Move, Start
  2. Counting the Ways
  3. The Longest Climb
  4. The Knapsack
  5. The Salesman Comes Back

Unit 8: Maps and Mazes

Graphs, and the two ways to walk one

  1. Getting the Map Into the Computer
  2. Going Deep
  3. Going Wide
  4. Out of the Maze

Unit 9: Shortest Roads

Three algorithms, three prices

  1. Keep Relaxing
  2. Dijkstra
  3. Every Pair at Once
  4. Which One, and When

Unit 10: One Way Only

Graphs with no way back

  1. Putting Jobs in Order
  2. Counting Along the Order
  3. One Exit Each
  4. The Critical Path

Unit 11: Going in Circles

Finding the loop, and where it starts

  1. Three Colours
  2. Loops Without Arrows
  3. Which Nodes Are In It
  4. Tortoise and Hare

Unit 12: Cheapest Network

Joining everything up for the least money

  1. Wiring Up the Village
  2. Are We in the Same Group?
  3. Kruskal
  4. Prim, and Going the Other Way

Unit 13: Trees

One route between any two places

  1. Hanging It Up
  2. Counting on the Way Back Up
  3. The Longest Journey
  4. The Nearest Shared Ancestor

Unit 14: Numbers and Primes

Arithmetic that survives a modulus

  1. Sieving for Primes
  2. Taking a Number Apart
  3. Working Under a Modulus
  4. Dividing Under a Modulus

Unit 15: Counting Without Listing

Answers with more digits than the universe has atoms

  1. Choose
  2. Pascal's Triangle
  3. Add Some, Take Some Back
  4. Catalan Numbers

Unit 16: Grids of Numbers

Doing a thousand million steps at once

  1. Multiplying Matrices
  2. Fibonacci in Thirty Steps
  3. Counting Walks
  4. Building Your Own Recurrence

Unit 17: Chance

Counting what has not happened yet

  1. Count the Good Ones
  2. What It Is Worth on Average
  3. Where the Chance Flows
  4. How Long Until It Happens

Unit 18: Winning Games

Both players play perfectly

  1. Winning and Losing Places
  2. Nim
  3. Grundy Numbers
  4. Many Heaps, Strange Rules

Unit 19: Multiplying Fast

The Fourier transform, and what it is for

  1. What Multiplying Really Is
  2. Points Instead of Coefficients
  3. The Points That Fold
  4. The Fast Fourier Transform

Unit 20: Round Trips

Which places can reach each other

  1. There and Back Again
  2. Kosaraju
  3. Squash It Into a DAG
  4. Joining the Map Up

Unit 21: Every Edge, Every Node

One easy problem and one impossible one

  1. The Bridges of Königsberg
  2. Walking It
  3. One-Way Tours
  4. Every Node Once

Unit 22: Weak Points

The one road, and the one town, that holds it together

  1. The Search Tree
  2. Bridges
  3. Articulation Points
  4. How Fragile Is the Network?

Unit 23: Flows

How much can get through at once

  1. Pipes and Undoing
  2. Edmonds–Karp
  3. Cuts and Matchings
  4. The Cheapest Way Through

Unit 24: Shapes and Sweeps

One sign answers most of geometry

  1. Left or Right?
  2. Do These Two Cross?
  3. The Elastic Band
  4. The Sweep Line

Unit 25: Words and Patterns

Finding a needle in a very long haystack

  1. A String as a Number
  2. The Prefix Function
  3. A Tree of Letters
  4. Three Ways to Find It

Other things to learn

Start learning — units 1–2 are free