Introduction to Competitive Programming

(Fall 2019)

The list of Kattis problems are selected from those listed on the Methods to Solve webpage, which is associated with the Competitive Programming 3 book.

Selection of USACO problems are limited to those before 2016.

  Key Ideas Example Problems Additional problems
Week 1
(Aug 19 -- Aug 23)
  • Sum and prefix sums: For many problems where data is stored in an 1D-array, computing the sum or prefix (or postfix) sums can reduce the complexity from O(n^2) to O(n).
  • For some problems, it is necessary to store these sums in another array, requiring O(n) extra memory. For other problems, maintaining a running sum suffices. Some problems requires storing information other than sum of prefix.
  • Map or Set: To store data for quick check of existence, one can use HashMap, HashSet, TreeMap, TreeSet.
Week 2
(Aug 26 -- Aug 30)
  • Two pointers: One maintains two pointers (indices) into either one array or two arrays, and move the pointers based on values at the pointers.
  • Sliding window: A window slides through an array (both ends of the window move along one direction). One maintains a summary of what are in the window, and decides how to slide based on that summary.
  • PriortyQueue: implements the functionality of a multiset where operations such as addition, removal, and finding smallest are all efficient (O(1) or O(log N)). Without duplicate, one can use TreeSet instead. With duplicate, one can use TreeMap instead.
Week 3 (Sep 2 -- Sep 6)
  • Difference array. With range updates (changing array A's elements in an range by a constant value), maintaining the array where each element represents difference of two adjacent elements in A makes each update constant time. Some discrete event simulation can be viewed as range updates along the time dimension. Difference array to prefix-sum array is differentiation to integration in calculus.
  • Balanced parenthesis strings.
  • Stacks. provides last-in-first-out access; used implicitly for implementing function calls, and can be explicitly used for many tasks.
Week 4 (Sep 9 -- Sep 13)
Week 5 (Sep 16 -- Sep 20)
  • Stack continued
  • Depth first search
  • Floodfill
Week 6 (Sep 23 -- Sep 27)
  • Breadth first search
Week 7 (Sep 30 -- Oct 4)
  • Strings
Week 8 (Oct 7 -- Oct 11) Second competition will cover the following topics.
  • Stack (See Week 3)
  • String (See Week 7)
  • DFS (See Week 5)
  • BFS (See Week 6)
Week 9 (Oct 14 -- Oct 18)
  • Binary Search and Meet-in-the-Middle
Week 10 (Oct 21 -- Oct 25)
  • Mathematics and geometry
Week 11 (Oct 28 -- Nov 1) Problem Topics
  • Binary search (see week 9)
  • Meet-in-the-Middle (see week 9)
  • Sliding window (see week 2)
  • Using data structures such as Set, Map, and PriorityQueue (see weeks 1 and 2)
  • Traversal on 2D grid (DFS and/or BFS) (see weeks 5 and 6)
Week 12 (Nov 4 -- Nov 8)
  • Review of competitions 2 and 3.