当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6963:I love playing games

题目描述
Alice and Bob play a game on an undirected graph $G$ consisting of $n$ vertices numbered $1$ to $n$, and $m$ edges.

Before the game starts, Alice is at vertex $x$, Bob is at vertex $y$. The game rules as follows:

* Alice goes first, then Bob. with moves alternating each turn.
* They try to get the vertex $z$. At the end of a turn, if Alice arrives but Bob does not, Alice wins; If Bob arrives but Alice does not, Bob wins; If both arrive or both fail to arrive, it will be considered a draw.
* In a move, the current player can choose not to move or move to a vertex adjacent to the current vertex, if there is an edge between the two vertex.
* The player cannot be on the same vertex at the same time except the start position and end position.
* Both of them play in the optimal way. (i.e If there is a strategy to win, win; if not, try to get to a draw)

Your task is to determine who wins if both of them choose the best operation in their rounds.
输入解释
There is only one test case for this question.

The first line contains an integer $T (T<=10000)$ . Then $T$ test cases follow.

Each test case contains $m+2$ lines.

The first line contains two integers $n$ and $m$ $(n\le10^3)$ — numbers of vertices and edges in graph respectively.

The second line contains three integers $x$,$y$ and $z$ — the initial position of Alice,the initial position of Bob and the end position of them.

The next $m$ lines contain edges descriptions. Each line contains two integers $x$ and $y$ ($1\le x\le n, 1\le y\le n$)— denoting that there is an undirected edge between the vertices numbered $x$ and $y$.

It is guaranteed that the sum of $n$ over all test cases doesn't exceed $10^5$ and the sum of $m$ over all test cases doesn't exceed $2*10^5$. The given graph may contain loops and multi-edges.
输出解释
Print $T$ integer, for each case, determine who wins. Output

* an integer 1 if Alice wins.
* an integer 2 if draw. i.e no one wins.
* an integer 3 if Bob wins.
输入样例
2
10 13
8 1 10
1 2
1 3
2 4
2 5
3 5
8 9
9 4
9 5
4 6
5 6
6 10
5 7
7 10
8 9
2 3 8
1 2
2 6
2 7
6 4
7 5
4 3
5 3
6 8
7 8
输出样例
1
1

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6963

最后修改于 2021-10-23T19:10:50+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 524288/524288K(Java/Others)