CF176C.Playing with Superglue
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Two players play a game. The game is played on a rectangular board with n × m squares. At the beginning of the game two different squares of the board have two chips. The first player's goal is to shift the chips to the same square. The second player aims to stop the first one with a tube of superglue.
We'll describe the rules of the game in more detail.
The players move in turns. The first player begins.
With every move the first player chooses one of his unglued chips, and shifts it one square to the left, to the right, up or down. It is not allowed to move a chip beyond the board edge. At the beginning of a turn some squares of the board may be covered with a glue. The first player can move the chip to such square, in this case the chip gets tightly glued and cannot move any longer.
At each move the second player selects one of the free squares (which do not contain a chip or a glue) and covers it with superglue. The glue dries long and squares covered with it remain sticky up to the end of the game.
If, after some move of the first player both chips are in the same square, then the first player wins. If the first player cannot make a move (both of his chips are glued), then the second player wins. Note that the situation where the second player cannot make a move is impossible — he can always spread the glue on the square from which the first player has just moved the chip.
We will further clarify the case where both chips are glued and are in the same square. In this case the first player wins as the game ends as soon as both chips are in the same square, and the condition of the loss (the inability to move) does not arise.
You know the board sizes and the positions of the two chips on it. At the beginning of the game all board squares are glue-free. Find out who wins if the players play optimally.
两名玩家进行一场游戏。游戏在一个 n×m 的矩形棋盘上进行。游戏开始时,棋盘上有两个不同的格子各放置一枚棋子。第一位玩家的目标是将两枚棋子移动到同一个格子;第二位玩家则试图用一管强力胶水阻止第一位玩家达成目标。
下面我们更详细地描述游戏规则:
- 玩家轮流行动,第一位玩家先行。
- 每次行动中,第一位玩家选择一枚尚未被粘住的棋子,并将其向左、右、上或下移动一格。不允许将棋子移出棋盘边界。在某轮行动开始时,棋盘上某些格子可能已被涂上胶水。第一位玩家可以将棋子移动到这样的格子上;此时该棋子即被牢牢粘住,此后无法再移动。
- 每次行动中,第二位玩家选择一个空闲格子(即既不含有棋子、也未被涂胶的格子),并在其上涂上强力胶水。胶水干燥时间极长,因此一旦涂胶,该格子在整个游戏过程中始终保持粘性。
- 若在第一位玩家某次移动之后,两枚棋子位于同一个格子,则第一位玩家获胜。
- 若第一位玩家无法行动(即他的两枚棋子均已被粘住),则第二位玩家获胜。注意:第二位玩家无法行动的情形不可能发生——他总可以将胶水涂在第一位玩家刚刚移出的那个格子上。
- 我们进一步明确一种特殊情况:若两枚棋子均已被粘住且位于同一格子,则第一位玩家获胜。因为游戏在两枚棋子首次处于同一格子时立即结束,而“无法行动”这一失败条件此时并未触发。
已知棋盘尺寸及初始时两枚棋子的位置。游戏开始时,棋盘上所有格子均未涂胶。请判断:若双方均采取最优策略,谁将获胜?
输入格式
The first line contains six integers n, m, _x_1, _y_1, _x_2, _y_2 — the board sizes and the coordinates of the first and second chips, correspondingly (1 ≤ n, m ≤ 100; 2 ≤ n × m; 1 ≤ _x_1, _x_2 ≤ n; 1 ≤ _y_1, _y_2 ≤ m). The numbers in the line are separated by single spaces.
It is guaranteed that the chips are located in different squares.
第一行包含六个整数 n、m、x1、y1、x2、y2 —— 分别表示棋盘的尺寸以及第一枚和第二枚棋子的坐标(1 ≤ n, m ≤ 100;2 ≤ n × m;1 ≤ x1, x2 ≤ n;1 ≤ y1, y2 ≤ m)。行内各数字以单个空格分隔。
保证两枚棋子位于不同的方格中。
输出格式
If the first player wins, print "First" without the quotes. Otherwise, print "Second" without the quotes.
如果先手玩家获胜,则输出 "First"(不带引号);否则输出 "Second"(不带引号)。
输入输出样例
输入#1
1 6 1 2 1 6
输出#1
First
输入#2
6 5 4 3 2 1
输出#2
First
输入#3
10 10 1 1 10 10
输出#3
Second
输入解题思路,AI测评打分。不知道怎么写?