Graph Theory37 sections · 1633 units
Open in Course

Problem - Game Routes

CSES 1681

You have a game with nn levels and mm teleporters. Each teleporter goes from level aa to level bb. You start at level 11 and want to reach level nn. How many different routes are there from level 11 to level nn?

Print the answer modulo 109+710^9 + 7. This is the counting version of the previous problem.

Instead of finding the longest path, you count all paths. The approach is the same: topological sort plus DP.

But instead of taking the max, you sum the ways. Before reading on, think: what would the DP state be?

What's the transition?