IBMOA #71
Visible Profiles Count
估计中等可在线判题
考点(AI 标注)并查集
Users are numbered 1..n, and undirected connections can be followed over multiple hops. Each query returns the number of users in that user's connected component, including the user; the answer for an isolated user is 1. The original example wrote the visible list of an isolated node as empty, yet explicitly counted the user themselves; this statement corrects it accordingly.
输入格式
The first line contains n m q, followed by m lines of edges u v, and finally q query numbers. This site adds 1≤n,q≤200000, 0≤m≤200000, and all endpoints and queries are in 1..n. Self-loops and multiple edges are allowed, and the graph need not be connected.
输出格式
Output q integers in query order.
样例 1
输入:
7 4 4
1 2
2 3
3 4
5 6
1 3 5 7
输出:
4 4 2 1
样例 2
输入:
3 0 3
1 2 3
输出:
1 1 1
样例 3
输入:
3 3 3
1 1
1 2
2 1
1 3 2
输出:
2 1 2
样例说明
The outputs of the three public examples are, in order: 4 4 2 1; 1 1 1; 2 1 2. These answers were verified by independent enumeration or direct simulation.