Graph Theory37 sections · 1633 units
Open in Course

CSES 1673 High Score - Problem Statement

(CSES - Bellman-Ford trap)

You play a game on a directed graph with N nodes. Each edge has a score (can be negative). Find the maximum score when traveling between node 11 and node N.

If you can achieve arbitrarily high scores, print 1-1.

Constraints: N2500N \leq 2500, M5000M \leq 5000. Negative edges exist, so this is not a standard shortest-path problem. You need to handle negative weights and detect if a positive cycle (in the original graph) affects the path from 11 to NN.