#BF0000017. Núi vàng (The Mountain of Gold?)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Núi vàng (The Mountain of Gold?)
The Mountain of Gold?
Source: BOJ
Version: Phuoc Hung OJ Extended
Problem Statement
There are mountains numbered through , with mountain being Ledang. Each of the one-way portals changes time by years when traversed. Every mountain is reachable from mountain . Determine whether one can start at mountain , traverse at least two portals, and return to mountain at a strictly earlier time.
Input
The first line contains , followed by lines . Every edge connects two distinct vertices.
Output
Print possible if a strictly negative-time closed walk from mountain back to itself exists; otherwise print not possible.
Subtasks
-
Subtask 1 (20 points): ; ; ; every vertex reachable from , no self-loops.
-
Subtask 2 (30 points): ; ; ; every vertex reachable from , no self-loops.
-
Subtask 3 (50 points): ; ; ; every vertex reachable from , no self-loops.
Examples
Input
2 2
0 1 15
1 0 -20
Output
possible
Explanation
The route changes time by , returning to mountain five years earlier.