题目描述
Problem Description
An undirected graph with numbered vertices is called a good graph if it can have a spanning tree $ T $ that satisfies the following conditions. Note that an edge connecting two vertices $u,v\ (u < v)$ is denoted as edge $ (u,v) $.
- For every edge $(u,v)\ (u < v)$ in the graph, on the unique simple path connecting vertices $ u $ and $ v $ in $ T $, the minimum and maximum vertex numbers on the path are $ u $ and $ v $, respectively.
There is a simple connected undirected graph $ G $ with $ N $ vertices numbered from $ 1 $ to $ N $. The graph $ G $ has $ M $ edges, where the $ i $-th edge connects vertices $A_i, B_i\ (A_i < B_i)$.
For each $i = 1, 2, \dots, M$, determine if the graph obtained by removing the $ i $-th edge from $ G $ is a good graph.
Input Format
The input is given from the standard input in the following format:
$ N $ $ M $ $ A_1 $ $ B_1 $ $\vdots$ $ A_M $ $ B_M $
Output Format
Output $ M $ lines. The $ i $-th line should contain Yes if the graph obtained by removing the $ i $-th edge from $ G $ is a good graph, and No otherwise.
Sample Input and Output
Sample Input #1
6 9
1 3
1 5
2 5
2 6
3 4
3 5
3 6
4 6
5 6
Sample Output #1
No
No
No
No
Yes
No
No
Yes
Yes
Sample Input #2
5 4
1 2
2 3
3 4
4 5
Sample Output #2
No
No
No
No
Sample Input #3
15 20
12 13
7 8
5 7
8 10
9 12
4 5
11 12
2 4
6 8
4 14
1 2
14 15
2 9
3 8
2 15
10 11
13 14
8 9
7 14
5 13
Sample Output #3
No
No
No
Yes
Yes
No
Yes
No
No
No
No
No
No
No
No
Yes
No
No
No
No
Notes/Hints
Constraints
- $2 \leq N \leq 2 \times 10^5$
- $N - 1 \leq M \leq 2 \times 10^5$
- $1 \leq A_i < B_i \leq N$
- All values in the input are integers
- The given graph is a simple connected undirected graph
Sample Explanation 1
Consider the case where edge $ (4,6) $ is removed, and a spanning tree consisting of edges $ (1,3), (2,5), (3,4), (3,5), (5,6) $. For edge $ (3,6) $, the simple path connecting vertices $ 3 $ and $ 6 $ is $ 3, 5, 6 $, and the minimum and maximum vertex numbers on this path are $ 3 $ and $ 6 $, respectively, satisfying the condition. Checking other edges similarly shows that this spanning tree satisfies the condition. Thus, the answer is Yes. On the other hand, consider the case where edge $ (1,5) $ is removed. For edge $ (4,6) $, the simple path connecting vertices $ 4 $ and $ 6 $ is $ 4, 3, 5, 6 $, and the minimum and maximum vertex numbers on this path are $ 3 $ and $ 6 $, respectively, not satisfying the condition. It can be shown that no other spanning tree satisfies the condition, so the answer is No.
Sample Explanation 2
Removing an edge can result in a graph that is no longer connected.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分