Graph Destruction

AtCoder
IDabc229_e
Time2000ms
Memory256MB
Difficulty
Given is an undirected graph with $N$ vertices and $M$ edges. Edge $i$ connects Vertices $A_i$ and $B_i$. We will erase Vertices $1, 2, \ldots, N$ one by one. Here, erasing Vertex $i$ means deleting Vertex $i$ and all edges incident to Vertex $i$ from the graph. For each $i=1, 2, \ldots, N$, how many connected components does the graph have when vertices up to Vertex $i$ are deleted? ## Constraints * $1 \leq N \leq 2 \times 10^5$ * $0 \leq M \leq \min(\frac{N(N-1)}{2} , 2 \times 10^5 )$ * $1 \leq A_i \lt B_i \leq N$ * $(A_i,B_i) \neq (A_j,B_j)$ if $i \neq j$. * All values in input are integers. ## Input Input is given from Standard Input in the following format: $N$ $M$ $A_1$ $B_1$ $A_2$ $B_2$ $\vdots$ $A_M$ $B_M$ [samples]
Samples
Input #1
6 7
1 2
1 4
1 5
2 4
2 3
3 5
3 6
Output #1
1
2
3
2
1
0

![image](https://img.atcoder.jp/ghi/3320212a9093132a80105bf02feeb195.png)  
The figure above shows the transition of the graph.
Input #2
8 7
7 8
3 4
5 6
5 7
5 8
6 7
6 8
Output #2
3
2
2
1
1
1
1
0

The graph may be disconnected from the beginning.
API Response (JSON)
{
  "problem": {
    "name": "Graph Destruction",
    "description": {
      "content": "Given is an undirected graph with $N$ vertices and $M$ edges.   Edge $i$ connects Vertices $A_i$ and $B_i$. We will erase Vertices $1, 2, \\ldots, N$ one by one.   Here, erasing Vertex $i$ means deleti",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc229_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given is an undirected graph with $N$ vertices and $M$ edges.  \nEdge $i$ connects Vertices $A_i$ and $B_i$.\nWe will erase Vertices $1, 2, \\ldots, N$ one by one.  \nHere, erasing Vertex $i$ means deleti...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments