Graph Theory37 sections · 1633 units
Open in Course

Problem - Game Routes

CSES 1681

This problem asks: How many different routes are there from city 11 to city nn in a flight network (DAG)?

The answer can be huge, so return it modulo 109+710^9 + 7. A route is a sequence of cities where you can fly from each city to the next. This is a path counting problem on a DAG.

Instead of taking min or max when relaxing edges, you add: dp[v] = dp[v] + dp[u] for each edge (u,v)(u, v). Each path to uu extends to a path to vv.