atcoder#ABC229E. [ABC229E] Graph Destruction

[ABC229E] Graph Destruction

Score : 500500 points

Problem Statement

Given is an undirected graph with NN vertices and MM edges. Edge ii connects Vertices AiA_i and BiB_i.

We will erase Vertices 1,2,,N1, 2, \ldots, N one by one. Here, erasing Vertex ii means deleting Vertex ii and all edges incident to Vertex ii from the graph.

For each i=1,2,,Ni=1, 2, \ldots, N, how many connected components does the graph have when vertices up to Vertex ii are deleted?

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^5
  • $0 \leq M \leq \min(\frac{N(N-1)}{2} , 2 \times 10^5 )$
  • 1Ai<BiN1 \leq A_i \lt B_i \leq N
  • (Ai,Bi)(Aj,Bj)(A_i,B_i) \neq (A_j,B_j) if iji \neq j.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM

A1A_1 B1B_1

A2A_2 B2B_2

\vdots

AMA_M BMB_M

Output

Print NN lines. The ii-th line should contain the number of connected components in the graph when vertices up to Vertex ii are deleted.

6 7
1 2
1 4
1 5
2 4
2 3
3 5
3 6
1
2
3
2
1
0

The figure above shows the transition of the graph.

8 7
7 8
3 4
5 6
5 7
5 8
6 7
6 8
3
2
2
1
1
1
1
0

The graph may be disconnected from the beginning.