Graph Theory37 sections · 1633 units
Open in Course

Problem - Hamiltonian Flights

CSES 1690 - Bitmask DP.

Problem: There are nn cities with mm one-way flights. Count the number of routes from city 11 to city nn that visit every city exactly once.

Link: CSES 1690

Constraints:

  • 2n202 \leq n \leq 20
  • 1mn21 \leq m \leq n^2

Note: This is Hamiltonian path counting. The small nn suggests bitmask DP. The state is (current city, set of visited cities). Transition: move to an adjacent unvisited city and add it to the visited set.