296
传统题
[ABC266F] 基环树唯一简单路径 (Well-defined Path Queries on a Namori)
[ABC266F] 基环树唯一简单路径 (Well-defined Path Queries on a Namori)
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).
Input
Input is given from Standard Input in the following format:
$N$
$u_1$ $v_1$
$u_2$ $v_2$
$\vdots$
$u_N$ $v_N$
$Q$
$x_1$ $y_1$
$x_2$ $y_2$
$\vdots$
$x_Q$ $y_Q$
Output
Print lines.
The -th line should contain Yes if there is a unique simple path from Vertex to Vertex , and No otherwise.
Example
5
1 2
2 3
1 3
1 4
2 5
3
1 2
1 4
1 5
No
Yes
No
Note
-
Constraints:
-
-
-
if .
-
is a connected simple undirected graph with vertices and edges.
-
-
-
All values in input are integers.
-
Source: ABC266F