#abc264e. E - Blackout 2

E - Blackout 2

Score : 500500 points

问题描述

一个国家拥有 NN 座城市和 MM 座发电厂,我们统称这些地方。
这些地方编号为 1,2,,N+M1,2,\dots,N+M,其中地方 1,2,,N1,2,\dots,N 是城市,地方 N+1,N+2,,N+MN+1,N+2,\dots,N+M 是发电厂。

该国拥有 EE 条输电线路。第 ii 条输电线路(1iE1 \le i \le E)双向连接地方 UiU_i 和地方 ViV_i
如果从一座城市出发,可以通过一些输电线路至少到达一座发电厂,则称这座城市已通电

现在,将发生 QQ 个事件。在第 ii 个事件(1iQ1 \le i \le Q)中,第 XiX_i 条输电线路断裂,变得无法使用。一旦输电线路断裂,在后续的事件中它将保持断裂状态。

找出每个事件发生后已通电城市的数量。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

A country has NN cities and MM power plants, which we collectively call places.
The places are numbered 1,2,,N+M1,2,\dots,N+M, among which Places 1,2,,N1,2,\dots,N are the cities and Places N+1,N+2,,N+MN+1,N+2,\dots,N+M are the power plants.

This country has EE power lines. Power Line ii (1iE1 \le i \le E) connects Place UiU_i and Place ViV_i bidirectionally.
A city is said to be electrified if one can reach at least one of the power plants from the city using some power lines.

Now, QQ events will happen. In the ii-th (1iQ1 \le i \le Q) event, Power Line XiX_i breaks, making it unusable. Once a power line breaks, it remains broken in the succeeding events.

Find the number of electrified cities right after each events.

Constraints

  • All values in input are integers.
  • 1N,M1 \le N,M
  • N+M2×105N+M \le 2 \times 10^5
  • 1QE5×1051 \le Q \le E \le 5 \times 10^5
  • 1Ui<ViN+M1 \le U_i < V_i \le N+M
  • If iji \neq j, then UiUjU_i \neq U_j or ViVjV_i \neq V_j.
  • 1XiE1 \le X_i \le E
  • XiX_i are distinct.

Input

Input is given from Standard Input in the following format:

NN MM EE

U1U_1 V1V_1

U2U_2 V2V_2

\vdots

UEU_E VEV_E

QQ

X1X_1

X2X_2

\vdots

XQX_Q

Output

Print QQ lines.
The ii-th line should contain the number of electrified cities right after the ii-th event.

Sample Input 1

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

Sample Output 1

4
4
2
2
2
1

Initially, all cities are electrified.

  • The 11-st event breaks Power Line 33 that connects Point 55 and Point 1010.
    • Now City 55 is no longer electrified, while 44 cities remain electrified.
  • The 22-nd event breaks Power Line 55 that connects Point 22 and Point 99.
  • The 33-rd event breaks Power Line 88 that connects Point 33 and Point 66.
    • Now Cities 22 and 33 are no longer electrified, while 22 cities remain electrified.
  • The 44-th event breaks Power Line 1010 that connects Point 11 and Point 88.
  • The 55-th event breaks Power Line 22 that connects Point 44 and Point 1010.
  • The 66-th event breaks Power Line 77 that connects Point 11 and Point 77.
    • Now City 11 is no longer electrified, while 11 city remains electrified.

update @ 2024/3/10 11:09:44