21905_BombGame

2022-5-16 18:20| 发布者: Hocassian| 查看: 22| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505946371500-Problem List-采集的数据-后羿采集器.html

Pro.ID

21905

Title

Bomb Game

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21905

AC

3

Submit

14

Ratio

21.43%

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/32768 K (Java/Others)
  • 描述

    John and Jack, two mathematicians, created a game called "Bomb Game" at spared time. This game is played on an n*m chessboard. A pair of integers (p, q) represents the grid at row p, column q. Some bombs were placed on the chessboard at the beginning. Every round, a player can choose to explode a bomb located at (p, q), and the exploded bomb will disappear. Furthermore:

    1. If p > 1 and q > 1, the bomb will split up into two bombs located at (u, q) and (p, v), u < p, v < q, u and v are chosen by the player.

    2. If p = 1 and q > 1, one new bomb will be produced, located at (p, v), v < q, v can be chosen freely by the player.

    3. If q = 1 and p > 1, one new bomb will be produced, located at (u, q), u < p, u can be chosen freely by the player.

    If two bombs located at the same position or a bomb located at (1, 1), they will be exploded automatically without producing new bombs.

    Two players play in turn, until one player cannot explode the bombs and loses the game.

    John always plays first.

    Now, we'll give you an initial situation, and you should tell us who will win at last. Assume John and Jack are smart enough, and they always do the best choice.

    输入

    There are several test cases, each one begins with two integers n and m, 0 < n, m ≤ 50, represents the number of rows and columns. Following by an n*m grid, describing the initial situation, '#' indicates bomb.

    The input is terminated by n=m=0.

    输出

    Description

    John and Jack, two mathematicians, created a game called "Bomb Game" at spared time. This game is played on an n*m chessboard. A pair of integers (p, q) represents the grid at row p, column q. Some bombs were placed on the chessboard at the beginning. Every round, a player can choose to explode a bomb located at (p, q), and the exploded bomb will disappear. Furthermore:

    1. If p > 1 and q > 1, the bomb will split up into two bombs located at (u, q) and (p, v), u < p, v < q, u and v are chosen by the player.

    2. If p = 1 and q > 1, one new bomb will be produced, located at (p, v), v < q, v can be chosen freely by the player.

    3. If q = 1 and p > 1, one new bomb will be produced, located at (u, q), u < p, u can be chosen freely by the player.

    If two bombs located at the same position or a bomb located at (1, 1), they will be exploded automatically without producing new bombs.

    Two players play in turn, until one player cannot explode the bombs and loses the game.

    John always plays first.

    Now, we'll give you an initial situation, and you should tell us who will win at last. Assume John and Jack are smart enough, and they always do the best choice.

    Input

    There are several test cases, each one begins with two integers n and m, 0 < n, m ≤ 50, represents the number of rows and columns. Following by an n*m grid, describing the initial situation, '#' indicates bomb.

    The input is terminated by n=m=0.

    Output

    For each test case, output one line, the name of the winner.

    Sample Input

    2 2
    .#
    ..
    2 2
    .#
    .#
    0 0

    Sample Output

    John
    Jack

    Source

    样例输入

    2 2
    .#
    ..
    2 2
    .#
    .#
    0 0

    样例输出

    John
    Jack

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部