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
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Given a directed graph which contains ~n~ vertices (indexed from ~1~ to ~n~) and ~m~ edges. Given q querries and each queries contains two integers ~a~ and ~b~. For each queries, determine if there is an edge from ~a~ to ~b~.
Input
- The first line contains three integers ~n, m, q~ ~(n, m, q \le 10^5)~
- Each line in the next ~m~ lines contains two integers ~u~ and ~v~ which is an edge from ~v~ to ~u~.
- Each line in the next ~q~ lines contains two integers ~a~ and ~b~ ~(1 \le a, b \le n)~.
Output
For each query, output Y
if there is a edge exists, otherwise output N
(without the quote) in a single line.
Example Input
3 4 2
1 2
1 3
2 3
3 1
1 3
1 2
Example Output
Y
N
Bình luận