PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FW0000036. So sánh mạng bay (Airline Comparison)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
So sánh mạng bay (Airline Comparison)
Airline Comparison
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Two airlines have directed flight networks over uppercase-letter cities. Determine whether the networks have the same reachability relation for every ordered pair.
Input
Integer and uppercase-letter directed edges for network 1, then and edges for network 2.
Output
Print YES if both networks induce the same reachability, otherwise NO.
Subtasks
- Subtask 1 (40 points): ; ; endpoints are
A–Z, no loops or duplicate directed edges. - Subtask 2 (60 points): ; endpoints are
A–Z, no loops or duplicate directed edges.
Examples
Input
2
A B
B C
3
A B
B C
A C
Output
YES
Explanation
The extra direct route A to C in the second graph was already implied by A to B to C in the first, so the reachable ordered pairs coincide.