Graph Theory37 sections · 1633 units
Open in Course

Problem - Coin Collector

CSES 1686 - SCC and DP.

Problem: A game has nn rooms and mm one-way tunnels. Each room has coins. You start in any room and keep moving through tunnels, collecting coins. Find the maximum coins you can collect.

Link: CSES 1686

Constraints:

  • 1n1051 \leq n \leq 10^5
  • 1m2×1051 \leq m \leq 2 \times 10^5

Hint: You can stay in a cycle collecting coins repeatedly. What does that tell you about SCCs?