Submit | All submissions | Best solutions | Back to list |
EISCOPN - Question 3 |
You are given an undirected graph that has n vertices and m edges. You are also given q queries, each of them contains two vertices a and b. You should check if there is a path between a and b.
Input
The first line contains 3 integers n, m, q (0 < n, m ≤ 105).
Each of the next m lines contains two integers u, v representing an edge connecting vertex u and vertex v (0 ≤ u, v < n).
Each of the next q lines contains two integers a and b, representing a query (0 ≤ a, b < n).
Output
For each query, print “YES” if there is a path between two vertices, otherwise print “NO”. The output is case-sensitive.
Sample
https://drive.google.com/file/d/1Lu4JPqxvw8etw0d6OWHzeAVsqY0TJyAn/view?usp=sharing
Input |
Output |
5 4 3 0 1 1 2 2 3 0 3 1 3 1 0 0 4 |
YES YES NO |
Added by: | Ha Minh Ngoc |
Date: | 2021-07-11 |
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 |