#abc229e. E - Graph Destruction
E - Graph Destruction
Score : points
问题陈述
给定一个含有 个顶点和 条边的无向图。
边 连接顶点 和 。
我们将按照顺序逐一擦除顶点 。
其中,擦除顶点 意味着从图中删除顶点 及其所有连接到顶点 的边。
对于每个 ,在擦除了从顶点 到顶点 之后,图中会有多少个连通分量?
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Given is an undirected graph with vertices and edges.
Edge connects Vertices and .
We will erase Vertices one by one.
Here, erasing Vertex means deleting Vertex and all edges incident to Vertex from the graph.
For each , how many connected components does the graph have when vertices up to Vertex are deleted?
Constraints
- $0 \leq M \leq \min(\frac{N(N-1)}{2} , 2 \times 10^5 )$
- if .
- 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 the number of connected components in the graph when vertices up to Vertex are deleted.
Sample Input 1
6 7
1 2
1 4
1 5
2 4
2 3
3 5
3 6
Sample Output 1
1
2
3
2
1
0
The figure above shows the transition of the graph.
Sample Input 2
8 7
7 8
3 4
5 6
5 7
5 8
6 7
6 8
Sample Output 2
3
2
2
1
1
1
1
0
The graph may be disconnected from the beginning.
update @ 2024/3/10 10:01:27