Solves multi-step Silver problems
USACO Gold
- 30 lessons
- About 60 minutes per lesson
Move from applying a single template to deriving states and justifying a solution. Practise dynamic programming, weighted graphs, disjoint sets and Fenwick trees, then combine methods on past problems.
View the syllabus
What you’ll be able to do
- Specify DP states, transitions, base cases and evaluation order.
- Choose graph algorithms or data structures from edge weights, connectivity changes and query types.
- Validate combined solutions with a correctness argument, complexity and small-input comparisons.
Course syllabus
Open a module for the lesson breakdown, a worked example and an assignment.
Lessons 1–5 Dynamic programming: states and transitions
Derive a dynamic program from overlapping subproblems and check the definition on small inputs.
- Identify overlapping subproblems in recursive enumeration.
- Define dp[i] in one sentence and specify what i represents.
- Mark base cases, unreachable states and dependencies.
- Convert memoised recursion into a table evaluated in dependency order.
- Check a transition against a hand trace and exhaustive enumeration.
Lessons 6–10 Knapsack and 2D dynamic programming
Design two-dimensional states for capacity or grid positions, then decide when compression is valid.
- Define 0/1 knapsack states by item index and capacity.
- Derive the take and skip transitions.
- Use descending capacity in a one-dimensional table to prevent reusing an item.
- Count grid paths with obstacles using the state above and to the left.
- Test one item, zero capacity and unreachable cells.
Lessons 11–15 Weighted graphs and shortest paths
Choose an algorithm from the edge conditions and verify relaxations and unreachable nodes.
- Store weights in adjacency lists and distinguish directed and undirected edges.
- Derive relaxation as an improvement of tentative distance through one edge.
- Implement Dijkstra with a min-heap for nonnegative weights.
- Skip stale heap entries and handle unreachable nodes and large distances.
- Track predecessors to recover a path and verify on a small graph.
Lessons 16–20 Disjoint sets and connectivity
Handle connectivity and component sizes as edges are added.
- Start with one set per vertex and initialise parent pointers.
- Implement find to locate a representative through parent pointers.
- Merge by size and compress paths during lookups.
- Track component count and recognise a redundant union.
- Sort edges by weight and use disjoint sets to choose edges for a minimum spanning tree.
Lessons 21–25 Fenwick trees and dynamic range queries
Answer range sums efficiently even as the data changes.
- Identify the cost of frequent point updates to static prefix sums.
- Use one-based indexes and lowbit to describe each node’s range.
- Implement point updates and visit each affected node.
- Obtain inclusive range sums from prefixes and check the empty prefix.
- Compare each operation against a linear reference and analyse both costs.
Lessons 26–30 Combined problems, proofs and review
Decide which tool handles each part of a problem and verify the combined solution.
- Choose states, a graph model or dynamic aggregation from constraints.
- Combine sorting for rank compression with a Fenwick tree to count inversions.
- Write a correctness argument for the key transition or update.
- Design an exhaustive reference, random small inputs and important boundary cases.
- Organise approaches, code, checks and costs for two problems.
A sample exercise
Climb 1 or 2 stairs at a time. How many ordered routes reach stair 4?
See the worked example →Common questions
What is the first lesson?
Identify overlapping subproblems in recursive enumeration. · Dynamic programming: states and transitions
How can I check my progress?
Complete a set of Gold topic problems and explain the algorithm and complexity for each. For at least two, provide runnable code, small reference results and edge cases covering key transitions or operations.