atcoder#ABC266F. [ABC266F] Well-defined Path Queries on a Namori
[ABC266F] Well-defined Path Queries on a Namori
Score : points
Problem Statement
You are given a connected simple undirected graph with vertices numbered to and edges. The -th edge connects Vertex and Vertex bidirectionally.
Answer the following queries.
- Determine whether there is a unique simple path from Vertex to Vertex (a simple path is a path without repetition of vertices).
Constraints
- if .
- is a connected simple undirected graph with vertices and edges.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines.
The -th line should contain Yes
if there is a unique simple path from Vertex to Vertex , and No
otherwise.
5
1 2
2 3
1 3
1 4
2 5
3
1 2
1 4
1 5
No
Yes
No
The simple paths from Vertex to are and , which are not unique, so the answer to the first query is No
.
The simple path from Vertex to is , which is unique, so the answer to the second query is Yes
.
The simple paths from Vertex to are and , which are not unique, so the answer to the third query is No
.
10
3 5
5 7
4 8
2 9
1 2
7 9
1 6
4 10
2 5
2 10
10
1 8
6 9
8 10
6 8
3 10
3 9
1 10
5 8
1 10
7 8
Yes
No
Yes
Yes
No
No
Yes
No
Yes
No