AtCoder Beginner Contest 120
D
Decayed Bridges
AtCoder
⌀ 1355
原题
← C→
翻译中…

Problem Statement

翻译中…

There are $N$ islands and $M$ bridges.

翻译中…

The $i$-th bridge connects the $A_i$-th and $B_i$-th islands bidirectionally.

翻译中…

Initially, we can travel between any two islands using some of these bridges.

翻译中…

However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to the $M$-th bridge.

翻译中…

Let the inconvenience be the number of pairs of islands $(a, b)$ ($a < b$) such that we are no longer able to travel between the $a$-th and $b$-th islands using some of the bridges remaining.

翻译中…

For each $i$ $(1 \leq i \leq M)$, find the inconvenience just after the $i$-th bridge collapses.

翻译中…

Constraints

翻译中…
  • All values in input are integers.
  • $2 \leq N \leq 10^5$
  • $1 \leq M \leq 10^5$
  • $1 \leq A_i < B_i \leq N$
  • All pairs $(A_i, B_i)$ are distinct.
  • The inconvenience is initially $0$.
翻译中…

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

翻译中…

Output

翻译中…

In the order $i = 1, 2, ..., M$, print the inconvenience just after the $i$-th bridge collapses. Note that the answer may not fit into a $32$-bit integer type.

翻译中…

样例

Input #1
4 5
1 2
3 4
1 3
2 3
1 4
Output #1
0
0
4
5
6
For example, when the first to third bridges have collapsed, the inconvenience is $4$ since we can no longer travel between the pairs $(1, 2), (1, 3), (2, 4)$ and $(3, 4)$.
Input #2
6 5
2 3
1 2
5 6
3 4
4 5
Output #2
8
9
12
14
15
Input #3
2 1
1 2
Output #3
1
题目信息
题号
abc120_d
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。