#P8860. 动态图连通性
动态图连通性
Problem Description
Given a directed graph with vertices and edges, initially there exists a path from to .
You need to process queries. Each query gives a positive integer in . If the -th edge in the original graph still exists, and after deleting the -th edge of the original graph from the current graph there is still a path from to , then delete the -th edge of the original graph.
You need to report whether the -th edge was deleted in each query.
Note: once an edge is deleted in a query, it is deleted forever. That is, queries affect each other.
Input Format
The first line contains three positive integers , representing the number of vertices, the number of edges, and the number of queries in the directed graph.
The next lines each contain two positive integers , meaning the -th edge goes from to .
The next lines each contain one positive integer , with the same meaning as in the description.
Output Format
Output lines, each containing an integer or .
If the -th edge was deleted in this query, output , otherwise output .
5 6 5
1 2
2 3
3 5
2 4
4 5
5 1
1
2
3
4
5
0
1
1
0
0
10 11 8
1 2
2 7
2 5
1 4
4 5
4 8
8 9
9 5
3 2
3 6
5 10
10
5
11
10
3
7
1
4
1
1
0
0
1
0
1
0
Hint
Sample Explanation
In the first sample:
Initially, the edge set of the graph is .
If we delete the -st edge of the original graph, then there is no path from to , so we cannot delete the -st edge.
If we delete the -nd edge of the original graph, then there exists a path , so we can delete the -nd edge, and the edge set becomes .
If we delete the -rd edge of the original graph, then there exists a path , so we can delete the -rd edge, and the edge set becomes .
If we delete the -th edge of the original graph, then there is no path from to , so we cannot delete the -th edge.
If we delete the -th edge of the original graph, then there is no path from to , so we cannot delete the -th edge.
Constraints
| Test Point ID | Special Constraints | ||
|---|---|---|---|
| None | |||
| It is guaranteed that among all queries, at most edge is not deleted | |||
| It is guaranteed that among all queries, at most edges are not deleted | |||
| Treating the directed graph as an undirected graph still gives the correct answer | |||
| None | |||
For all testdata, . The given graph has no multiple edges or self-loops, and there exists a path from to .
The two provided large samples satisfy the constraints of test point and test point , respectively.
Translated by ChatGPT 5