Is there a path after removing an edge?
Xem dạng PDF
Gửi bài giải
Điểm:
1,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Given a directed graph includes ~n~ vertices (from ~1~ to ~n~) and ~m~ edges. Given ~q~ queries of two integers ~a~ and ~b~. For each query, you are allowed to remove at most one edge from the graph (you may choose not to remove any edge, or remove exactly one). After the removal, check if there is a path from ~a~ to ~b~ which visite at most one intermediate vertex.
Input
- The first line contains three integers ~n, m~ and ~q~ ~(n \le 10^4, m, q \le 10^5)~
- Each line in the next ~m~ lines contains two integer ~u~ and ~v~ which represented an edge from ~u~ to ~v~.
- Each line in the next ~m~ lines contains four integer ~a~ and ~b~ which represented two vertices and ~x~ and ~y~ which represented an edge from ~x~ to ~y~.
Output
- For each query, output in one line "Yes" if there is a path from a to b, otherwise output "No"
Example Input
4 4 2
1 2
1 3
2 3
3 4
1 4 2 3
1 4 1 3
Example Output
Yes
No
Bình luận