D - Score Attack
Time limit : 2sec / Memory limit : 256MB
Score : 400 points
Problem Statement
There is a directed graph with N vertices and M edges. The i-th edge (1≤i≤M) points from vertex ai to vertex bi, and has a weight ci. We will play the following single-player game using this graph and a piece.
Initially, the piece is placed at vertex 1, and the score of the player is set to 0. The player can move the piece as follows:
- When the piece is placed at vertex ai, move the piece along the i-th edge to vertex bi. After this move, the score of the player is increased by ci.
The player can end the game only when the piece is placed at vertex