luogu#P3854. [TJOI2008] 通讯网破坏
[TJOI2008] 通讯网破坏
Background
Due to conflicts over resources, countries and are on the verge of war. Country 's intelligence agency has obtained the layout of country 's communication network, where each city is a vertex, and some pairs of vertices are connected by undirected edges, indicating direct bidirectional communication between those cities. Country plans to strike first by destroying an intermediate city with nuclear weapons to sever the connection between two important cities and in country . That is, after removing vertex from the graph, and become disconnected. However, since country 's defenses are strong, such a nuclear strike can succeed only once and can destroy only one city.
Problem Description
The leaders of country have proposed many strategies. As the chief computer scientist of country , your task is to write a program to determine whether each strategy is feasible.
Input Format
The first line contains two integers and , representing the number of cities in country and the number of pairs of cities that can communicate directly. The next lines each contain two integers and , and , indicating that cities and can communicate directly. It is guaranteed that each pair appears at most once.
The next line contains an integer , representing the number of strategies proposed by the leaders of country . The next lines each contain three integers (, and are pairwise distinct), indicating that this strategy attempts to sever communication between and by destroying .
Output Format
Output lines, each indicating whether the corresponding strategy is feasible. If, after destroying , and cannot communicate, then the strategy is feasible and you should output on the -th line; otherwise, output .
5 6
1 2
1 3
2 3
3 4
3 5
4 5
3
1 5 3
1 5 4
4 5 3
yes
no
no
Hint
For of the testdata, .
For of the testdata, $1 \leq N \leq 20000,1\leq M\leq 100000,1 \leq Q \leq 100000$.
It is guaranteed that the original graph is connected.
Translated by ChatGPT 5