Submit | All submissions | Best solutions | Back to list |
EICON - Is connected? |
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<=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 <= a, b <=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 Output: Y N
Added by: | Ha Minh Ngoc |
Date: | 2015-12-23 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |