#P7520. [省选联考 2021 A 卷] 支配
[省选联考 2021 A 卷] 支配
Description
Given a directed graph with vertices and edges, whose vertices are numbered from to .
For any two vertices , if every path from vertex to vertex must pass through vertex , then vertex is said to dominate vertex . In particular, every vertex dominates itself.
For any vertex , the set of vertices in the graph that dominate vertex is called the dominator set of , denoted by .
Now there are independent queries. Each query gives a directed edge. You need to answer: after adding this edge to graph , for how many vertices does their dominator set change.
Input Format
The first line contains three integers , representing the number of vertices, the number of edges, and the number of queries, respectively.
The next lines each contain two integers , representing a directed edge from to .
The next lines each contain two integers , representing that in this query, an edge from to is added.
The data guarantees that in the given graph , all other vertices are reachable from vertex , and the graph contains no multiple edges or self-loops.
Output Format
For each query, output one line with one integer, representing the answer.
6 6 3
1 2
1 3
3 4
4 5
2 6
4 1
5 6
3 2
2 4
1
0
2
见附件中的 dominator/dominator2.in。
见附件中的 dominator/dominator2.ans。
见附件中的 dominator/dominator3.in。
见附件中的 dominator/dominator3.ans。
Hint
【Sample #1 Explanation】
For the original graph, the dominator sets of the six vertices are: , , , , , .
After adding , , and the dominator sets of other vertices remain unchanged.
After adding , no vertex’s dominator set changes.
After adding , , , and the dominator sets of other vertices remain unchanged.
【Constraints】
For all testdata: , , .
The detailed limits for each test point are shown in the table below:
| Test Point ID | Special Property | |
|---|---|---|
| None | ||
| None |
Translated by ChatGPT 5
京公网安备 11011102002149号