CodeForce 176C Playing with Superglue

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.


Input

The first line contains six integers n, m, x1, y1, x2, y2 — the board sizes and the coordinates of the first and second chips, correspondingly (1 ≤ n, m ≤ 100; 2 ≤ n × m; 1 ≤ x1, x2 ≤ n; 1 ≤ y1, y2 ≤ m). The numbers in the line are separated by single spaces.

It is guaranteed that the chips are located in different squares.

Output

If the first player wins, print "First" without the quotes. Otherwise, print "Second" without the quotes.

Examples
Input
1 6 1 2 1 6
Output
First
Input
6 5 4 3 2 1
Output
First
Input
10 10 1 1 10 10
Output
Second

OJ-ID:
CodeForce 176C

author:
Caution_X

date of submission:
20191012

tags:
easy problem

description modelling:
给定一个棋盘,两个棋子,双方轮流操作,A先走,每次移动一个棋子在相邻格子一格,B后走,每次可以在一个格子涂胶水,如果两个棋子可以重合,A赢,否则B赢

major steps to solve it:
1.如果棋盘“非常大”,可以猜想B一定会赢
2.此时我们讨论A赢得极限情况。
设开始时两个棋子分别在棋盘左上角和右下角,棋盘规模为:
1×5
2×5
3×5
4×4
时A恰好赢,其他情况下A都无法赢

AC code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,x1,x2,y1,y2;
    scanf("%d%d%d%d%d%d",&n,&m,&x1,&y1,&x2,&y2);
    int dmin,dmax;
    dmin=min(abs(x1-x2),abs(y1-y2));
    dmax=max(abs(x1-x2),abs(y1-y2));
    if((dmin==0&&dmax<=4)||(dmin==1&&dmax<=4)||(dmin==2&&dmax<=4)||(dmin==3&&dmax<=3)) printf("First\n");
    else printf("Second\n");
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/cautx/p/11716437.html