#P10517. 国土规划

    ID: 11685 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>洛谷原创O2优化洛谷月赛圆方树

国土规划

Problem Description

In a country’s territory, there are nn cities and mm roads. These mm roads connect the nn cities, meaning that for any two cities, there is a route that can reach one from the other directly or indirectly. There may be multiple roads between the same pair of cities, but there is no road whose two ends connect to the same city.

The country wants to select some cities for key development. Specifically, each city has an importance value aia_i, where ai=0a_i=0 means the city does not need key development, and ai=1a_i=1 means the city needs key development. Initially, all ai=0a_i=0.

The country performs qq planning operations. In each operation, a city xx is chosen and we set ax1axa_x \gets 1-a_x.

After each operation, as the chief planner, you need to find the number of cities pp such that ap=0a_p=0, and after city pp disappears (together with all roads directly connected to city pp), any two cities u,vu,v with au=av=1a_u=a_v=1 are still connected directly or indirectly.

Note that the planning is only hypothetical on paper, and no city is actually deleted.

Input Format

The first line contains three positive integers n,m,qn,m,q separated by spaces.

The next mm lines each contain two positive integers u,vu,v, describing a bidirectional road connecting cities uu and vv.

The next qq lines each contain one positive integer xx, describing one planning operation.

Output Format

Output qq lines. Each line contains one non-negative integer, which is the answer after each modification.

4 4 6
1 2
2 3
3 1
3 4
1
3
3
4
4
1
3
2
3
1
3
4

Hint

Sample Explanation

Take the 4th planning operation as an example. At this time, the cities that need key development are 11 and 44, so the only cities with ap=0a_p=0 are 22 and 33. If city 22 disappears, there is a path 1341-3-4. If city 33 disappears, then 11 and 44 cannot reach each other. Therefore, the only city that satisfies the condition is 22, and the answer is 11.

Constraints

  • For 15%15\% of the testdata, n,q300n,q \le 300, m500m \le 500.
  • For another 15%15\% of the testdata, m=n1m=n-1, and for all roads, v=u+1v=u+1.
  • For another 20%20\% of the testdata, m=n1m=n-1.

For all testdata, 2n1052 \le n \le 10^5, n1m2×105n-1\le m \le 2 \times 10^5, 1q2×1051 \le q \le 2 \times 10^5, 1u,v,xn1 \le u,v,x \le n, uvu \neq v.

Translated by ChatGPT 5