Alice and Bob are good friends, as in every other storyline. One day Alice and Bob are
playing an interesting game. The game is played on a directed graph with n vertices and m
edges, Alice and Bob have exactly one chess piece each. Initially, Bob’s chess piece is
placed on vertex x,while Alice’s chess piece is placed at vertex y. Bob plays first,
then Alice, then Bob, then Alice and so on.
During each move, the player must move his/her chess piece from the vertex his/her chess
piece currently at to an adjacent vertex, by traveling through exactly one directed edge.(Remember that the game is played on a directed graph.) If someone can’t make such a
move, he/she will be considered to lose the game.
There’s one additional rule: at any time,if Bob and Alice’s chess pieces are at the same
vertex, then Alice is consider to be the winner and the game ends up immediately.
Now you are given the initial situation, could you determine who is the winner? Please
note that neither Bob nor Alice will make any mistakes during the game, i.e. they both
play optimally. In case that the game never ends up, Bob is considered to be the winner.
【Input】
The first line of the input gives the number of test cases, T. T test cases follow.
For each test case, the first line contains two integers n and m (2 n 100,1 m n
× (n − 1)). Next m lines, each line contains two integers b and e, indicating there
is one directed edge from vertex b to vertex e. Last line contains two integers x and y
(1 x, y n, x ̸= y), which are Bob and Alice’s initial position. The graph contains no
self-loops or duplicate edges.
【Output】
For each test case output one line “Case #x: y”, where x is the case number (starting
from 1)and y is “Yes” (without quotes)if Bob can win or the game never ends up,
otherwise “No”(without quotes).
2014-ACM-ICPC-西安赛区区域赛-H. The Problem to Make You Happy-图上博弈论
#2014-ACM-ICPC-西安赛区区域赛-H. The Problem to Make You Happy-图上博弈论【Description】Alice and Bob are good friends, as in every other storyline. One day Alice and Bob areplaying an interesting game. The game...