whoashish's cp notes

Home

❯

1. Problem Solving

1. Problem Solving

Oct 08, 20262 min read

  • i. Attacking a Problem: A working toolkit for hard problems:
  • ii. Invariants, Parity and Extremal Arguments: The three arguments behind most ad hoc and constructive problems:
  • iii. Contribution and Complementary Counting: The two most common moves in counting problems:
  • iv. Proof Techniques: Proof is what turns “passes the samples” into “is correct”.
  • v. Constructive Algorithms: Constructive problems ask you to build an object, or report that none exists.
  • vi. Classic Puzzles: Famous puzzles that keep showing up as contest problems or as the core of one.
  • vii. Observation Toolkit: the brute force → table → guess → prove loop and the moves that produce observations (invariants, extremes, reversing the process, canonical forms).
  • viii. When the Answer Is Small: answers bounded by a constant: universal strategy, exact characterization of the cheaper cases, lower-bound proofs (permutation sort, mex to zero).
  • ix. Sorting and Ordering Observations: inversions and cycles, relative-order invariants, ants on a stick, sorted-order patterns (median, pairing, prefix maxima).
  • x. Parity, Coloring and Mod Observations: invariants mod k, permutation parity, the 15-puzzle solvability test, colouring arguments for tilings.
  • xi. Operations and Reachable States: reachability by canonical forms and invariants, swaps at distance k, commuting and self-inverse operations.
  • xii. Ad Hoc on Arrays and Strings: binary strings, alternating targets, palindrome rearrangement, MEX and run observations.
  • xiii. Ad Hoc Problem Set: practice problems (CSES, Codeforces, classics) with the key observation for each.
  • xiv. Permutation Constructions: LIS/LDS (Erdős–Szekeres), exactly k inversions, no adjacent consecutive values, derangements, involutions.
  • xv. Graph Constructions: Havel–Hakimi, trees with given diameter or degrees, k shortest paths, Mycielski, Turán, regular graphs.
  • xvi. Grid and Matrix Constructions: Latin and magic squares (odd, doubly even, LUX), snake paths, matrices with given row and column sums.
  • xvii. Sequence and Number Constructions: 3-AP-free and Sidon sets, binary splitting, gcd tricks, xor-and-sum pairs, sum-free sets.
  • xviii. Invariant-Based Constructions: invariant gives the condition, construction proves sufficiency; equalize by triple xor.
  • xix. Greedy Constructions: lexicographically smallest objects with a feasibility test; I/D pattern permutations.
  • xx. Interactive and Output-Only Constructions: constructing by queries (hidden permutation with mod queries), adaptive judges, output-only search.
  • xxi. Problem Reduction and Modeling: Most hard problems are a known problem in disguise.

21 items under this folder.

  • Oct 22, 2026

    iv. Proof Techniques

    • problem-solving
    • proofs
  • Oct 22, 2026

    vi. Classic Puzzles

    • problem-solving
    • puzzles
  • Oct 22, 2026

    xxi. Problem Reduction and Modeling

    • problem-solving
    • modeling
  • Oct 08, 2026

    i. Attacking a Problem

    • problem-solving
  • Oct 08, 2026

    ii. Invariants, Parity and Extremal Arguments

    • problem-solving
    • proofs
  • Oct 08, 2026

    iii. Contribution and Complementary Counting

    • problem-solving
    • counting
  • Oct 08, 2026

    v. Constructive Algorithms

    • problem-solving
    • constructive
  • Oct 08, 2026

    vii. Observation Toolkit

    • ad-hoc
    • observation
  • Oct 08, 2026

    viii. When the Answer Is Small

    • ad-hoc
    • observation
  • Oct 08, 2026

    ix. Sorting and Ordering Observations

    • ad-hoc
    • sorting
  • Oct 08, 2026

    x. Parity, Coloring and Mod Observations

    • ad-hoc
    • invariants
  • Oct 08, 2026

    xi. Operations and Reachable States

    • ad-hoc
    • reachability
  • Oct 08, 2026

    xii. Ad Hoc on Arrays and Strings

    • ad-hoc
    • strings
    • arrays
  • Oct 08, 2026

    xiii. Ad Hoc Problem Set

    • ad-hoc
    • problems
  • Oct 08, 2026

    xiv. Permutation Constructions

    • constructive
    • permutations
  • Oct 08, 2026

    xv. Graph Constructions

    • constructive
    • graphs
  • Oct 08, 2026

    xvi. Grid and Matrix Constructions

    • constructive
    • grids
  • Oct 08, 2026

    xvii. Sequence and Number Constructions

    • constructive
    • number-theory
  • Oct 08, 2026

    xviii. Invariant-Based Constructions

    • constructive
    • invariants
  • Oct 08, 2026

    xix. Greedy Constructions

    • constructive
    • greedy
  • Oct 08, 2026

    xx. Interactive and Output-Only Constructions

    • constructive
    • interactive