#P4334. Police Roadblock System
Police Roadblock System
Police Roadblock System
The police are setting up a new computer system to help capture criminals. The jurisdiction has \(N\) cities and \(E\) bidirectional roads connecting them, where the cities are numbered from 1 to \(N\). The system must answer two types of queries:
-
Query Type 1. Given two cities \(A\) and \(B\), and a specific road connecting cities \(G_1\) and \(G_2\), determine whether the criminals can travel from \(A\) to \(B\) if the road between \(G_1\) and \(G_2\) is blocked.
-
Query Type 2. Given three cities \(A\), \(B\), and \(C\), determine whether the criminals can travel from \(A\) to \(B\) if city \(C\) is completely cut off (i.e. no entry into \(C\)).
You are to implement this system.
inputFormat
The input begins with three integers \(N\), \(E\) and \(Q\) on one line, representing the number of cities, the number of roads, and the number of queries respectively.
Then \(E\) lines follow. Each line contains two integers \(u\) and \(v\), which indicates there is a bidirectional road between cities \(u\) and \(v\).
After that, \(Q\) lines follow, each representing a query. Each query is in one of the following formats:
-
For Query Type 1:
1 A B G1 G2
-
For Query Type 2:
2 A B C
\(A\) and \(B\) are the source and destination cities. For Query Type 1, \(G_1\) and \(G_2\) specify the road that is blocked. For Query Type 2, \(C\) is the city that cannot be used.
outputFormat
For each query, output a single line containing yes
if it is possible for the criminals to travel from \(A\) to \(B\) under the given condition, or no
otherwise.
sample
4 4 2
1 2
2 3
3 4
4 1
1 1 3 2 3
2 1 3 4
yes
yes
</p>