#P14449. [ICPC 2025 Xi'an R] Catch the Monster
[ICPC 2025 Xi'an R] Catch the Monster
题目描述
A prehistoric monster has arrived on Earth via Dr. Peter's time machine. You need to help Dr. Peter catch it.
The monster hides in a forest with vertices and edges. Here, a forest is an acyclic undirected graph that may consist of multiple trees. You can perform the following operations to catch the monster:
- First, you choose a vertex ().
- Then, if the monster is currently at vertex , it is caught.
- Otherwise, the monster remains uncaught, and it may move to any adjacent vertex to its current vertex after the operation, except vertex . Or it may choose not to move and stay at the same vertex.
We define a forest as if and only if there exists a finite sequence of vertices, such that regardless of the monster's initial position and how it moves, performing operations by selecting vertices in the order of can guarantee that the monster will be caught.
Now, you need to answer questions from Dr. Peter. In each question, he gives you an interval (). You need to tell him whether the subforest induced by the vertices whose indices are in (i.e., the graph formed by retaining only these vertices and the edges between them) is .
输入格式
The first line of the input contains three integers , , and (, , ), where is the number of vertices in the forest, in the number of edges in the forest, and is the number of queries.
The next lines of the input each contain two integers and (, ), representing an edge in the forest.
The next lines of the input each contain two integers and (), representing a query.
输出格式
For each query, output a single line if the subforest is ; otherwise, output a single line .
You can output the answer in any case (upper or lower). For example, the strings , , , and will be recognized as positive responses.
10 9 3
1 2
1 3
1 8
2 5
2 6
2 7
3 4
8 9
8 10
1 3
2 6
1 10
Yes
Yes
No
100000 1 1
1 2
1 9999
Yes
提示
In the first test case:
- In the first query, for the subforest , you can set .
- In the second query, for the subforest , you can set .
- In the third query, for the subforest , it can be proven that there does not exist a finite valid sequence .
In the second test case:
- In the only query, for the subforest , you can set .
京公网安备 11011102002149号