#P7353. [2020-2021 集训队作业] Tom & Jerry
[2020-2021 集训队作业] Tom & Jerry
Description
Given an undirected connected graph with vertices and edges, Tom and Jerry play chasing games on the graph.
In the -th game, Tom starts at vertex , and Jerry starts at vertex (both sides always know their own and the opponent’s positions). The rules are:
-
Jerry and Tom move alternately, with Jerry moving first.
-
In each move, Jerry may traverse any number of edges in the undirected graph (he may also choose not to move), but during the movement he must not pass through the vertex where Tom is currently located, otherwise he is caught.
-
In each move, Tom may traverse at most one edge in the undirected graph (he may also choose not to move).
-
If Tom reaches Jerry’s position after a move, Tom wins.
Tom tries his best to win, while Jerry tries his best to prevent Tom from winning.
Now, for each game, determine whether Tom is guaranteed to win within a finite number of moves.
Input Format
Line : three integers , representing the number of vertices, the number of edges, and the number of games.
Next lines: each line contains two integers , describing an undirected edge in the graph.
Next lines: each line contains two integers , representing the initial positions of the two players in one game.
Output Format
Output lines. For each game, if Tom can win within a finite number of turns, output Yes; otherwise output No.
8 10 3
1 2
2 3
3 4
4 1
6 4
5 6
6 7
8 7
8 5
8 6
6 4
4 5
5 7
No
Yes
No
Hint
[Sample Explanation]

In the first query, . Jerry first moves to . After that, in each round, if Jerry is adjacent to Tom after Tom’s move, Jerry only needs to move to the vertex in the cycle that is not adjacent to Tom, which guarantees that Tom cannot win.
In the second query, . No matter how Jerry moves, Tom only needs to go to . After that, Jerry may be in . In any case, Tom can catch Jerry in one step.
In the third query, . Jerry can use the same strategy as in the first query to make it impossible for Tom to win.
[Constraints]
This problem uses bundled testdata.
For of the data, , , .
The given undirected graph is guaranteed to be connected, and has no multiple edges or self-loops.
: .
: .
: .
: .
: no special restrictions.
Translated by ChatGPT 5
京公网安备 11011102002149号