CF1609D.Social Network

传统题 时间 2000 ms 内存 256 MiB 10 尝试 1 已通过 1 标签

Social Network

CF1609D · Social Network

中文题意

以下为官方英文题意(课堂讲解时请要求学生能用自己的话复述条件与目标)。

William arrived at a conference dedicated to cryptocurrencies. Networking, meeting new people, and using friends' connections are essential to stay up to date with the latest news from the world of cryptocurrencies. The conference has nn participants, who are initially unfamiliar with each other. William can introduce any two people, aa and bb, who were not familiar before, to each other. William has dd conditions, ii'th of which requires person xix_i to have a connection to person yiy_i. Formally, two people xx and yy have a connection if there is such a chain p1=x,p2,p3,,pk=yp_1=x, p_2, p_3, \dots, p_k=y for which for all ii from 11 to k1k - 1 it's true that two people with numbers pip_i and pi+1p_{i + 1} know each other. For every ii (1id1 \le i \le d) William wants you to calculate the maximal number of acquaintances one person can have, assuming that William satisfied all conditions from 11 and up to and including ii and performed exactly ii introductions. The conditions are being checked after William performed ii introductions. The answer for each ii must be calculated independently. It means that when you compute an answer for ii, you should assume that no two people have been introduced to each other yet.

Note(官方): The explanation for the first test case: In this explanation, the circles and the numbers in them denote a person with the corresponding number. The line denotes that William introduced two connected people. The person marked with red has the most acquaintances. These are not the only correct ways to introduce people.

输入格式(中文)

The first line contains two integers nn and dd (2n103,1dn12 \le n \le 10^3, 1 \le d \le n - 1), the number of people, and number of conditions, respectively. Each of the next dd lines each contain two integers xix_i and yiy_i (1xi,yin,xiyi1 \le x_i, y_i \le n, x_i \neq y_i), the numbers of people which must have a connection according to condition ii.

输出格式(中文)

Output dd integers. iith number must equal the number of acquaintances the person with the maximal possible acquaintances will have, if William performed ii introductions and satisfied the first ii conditions.

样例

样例 1

输入:

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

输出:

1
1
3
3
3
6

样例 2

输入:

10 8
1 2
2 3
3 4
1 4
6 7
8 9
8 10
1 4

输出:

1
2
3
4
5
5
6
8

在线编程 IDE

建议全屏模式获得最佳体验