ICPC UNIVERSITY

Search the commons

Start typing to search pages, curriculum topics, practice, tools, and events.

Course II · Regional

Build the regional toolkit.

A usable first module for disjoint sets, range queries, stronger graphs, and regional-level practice.

LEARN · ICPC U
LEARNExplore the commons

COURSE II · REGIONAL · VERSION 2

Disjoint sets and range queries

Estimated time
4–6 hours
Prerequisites
Course I fluency, prefix sums, and graph traversal

Measurable outcome: Implement DSU and a Fenwick tree from memory, explain their invariants, and select the right structure under contest pressure.

01 · LEARN

Concept checklist

  • Path compression and union by size
  • Component invariants and amortized complexity
  • Prefix sums as a bridge to Fenwick trees
  • Point updates, prefix queries, and coordinate compression
Open the attributed reference ↗
02 · BUILD

Implementation lab

  1. Write DSU with find, unite, same, and size operations.
  2. Write a 1-indexed Fenwick tree with add and prefix-sum operations.
  3. Create randomized tests against a slow reference implementation.
04 · VERIFY

Exit criteria

  • Explain the key invariant without notes.
  • Reimplement the core technique in one sitting.
  • Solve two mapped tasks without editorial help.
  • Record one mistake and the test that exposes it.
Open the full starter set →

Keep moving

Your next step
is ready.

Continue to Course III