PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BF0000042. Các chuyến bay (Flights)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Các chuyến bay (Flights)
Flights
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
The flight network is a directed acyclic graph. Give each flight duration or such that every route from city to city has the same travel time, or print No.
Input
First line ; then lines .
Output
Print No, or print Yes followed by durations ( or ) in input order.
Subtasks
- Subtask 1 (20 points): , ; ; no duplicate arcs; a path from to exists.
- Subtask 2 (30 points): , ; ; no duplicate arcs; a path from to exists.
- Subtask 3 (50 points): , ; ; no duplicate arcs; a path from to exists.
Examples
Input
3 3
1 2
2 3
1 3
Output
Yes
1
1
2
Explanation
The two-flight route takes hours. Setting the direct flight duration to gives the same total time. Thus is a valid set of flight durations.