21944_Battleship

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

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

Pro.ID

21944

Title

Battleship

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    When playing battleship, players take turns trying to sink the other players navy. Each player may take shots at one coordinate at once. If he hits one of his enemy's ships and the enemy has any other ships left, he may continue. Else, the other player may take shots. After hitting a ship at one coordinate, shooting at that coordinate again counts as a miss.

    The game is nished when every part of every ship of a navy of one player has been hit. The fi rst player starts, and every player gets the same number of turns. That means, that the second player might get another turn even if all his ships have been sunk.

    The game ends with a draw if both navies are completely sunk, or if there are still ships left after all shots have been red.

    Tom the little spy watches a game of battleships between two fleet admirals. As he has successfully tapped the communication wires, he can intercept the shot orders. However, he was unable to determine which admiral ordered what shot to be red. After the game, he successfully breaks into the super secret game management facility, and manages to secure the  fleet deployment maps. As he wants to determine which fleet admiral is more dangerous, he wants to know which admiral won. He transmits the deployment maps and the shot orders, and wants you to determine which admiral won.

    输入

    Input starts with one line, containing the number of test cases t (0 < t ≤ 20).

    Every test case starts with a line, containing three integers w, h and n (1 ≤ w, h ≤ 30; 1 ≤ n ≤ 2000), describing the width and height of the fleet deployment maps, and the number of shots.

    The next h lines contain the deployment map for player one. Each line contains w field descriptions, where '_' means "water" and '#' means "ship". Then follow h lines containing the deployment map for player two.

    The following n lines contain the shot orders; each order consists of two integers, the x and y coordinate of the shot. The x coordinate indicates the column of the shot, running from 0 to w - 1, with 0 meaning the leftmost column. The y coordinate indicates the line of the shot, running from 0 to h - 1, with 0 meaning the last line, and h - 1 meaning the first line of the respective map.

    Please note that there may be more shot orders than needed to end the game.

    输出

    Description

    When playing battleship, players take turns trying to sink the other players navy. Each player may take shots at one coordinate at once. If he hits one of his enemy's ships and the enemy has any other ships left, he may continue. Else, the other player may take shots. After hitting a ship at one coordinate, shooting at that coordinate again counts as a miss.

    The game is nished when every part of every ship of a navy of one player has been hit. The fi rst player starts, and every player gets the same number of turns. That means, that the second player might get another turn even if all his ships have been sunk.

    The game ends with a draw if both navies are completely sunk, or if there are still ships left after all shots have been red.

    Tom the little spy watches a game of battleships between two fleet admirals. As he has successfully tapped the communication wires, he can intercept the shot orders. However, he was unable to determine which admiral ordered what shot to be red. After the game, he successfully breaks into the super secret game management facility, and manages to secure the  fleet deployment maps. As he wants to determine which fleet admiral is more dangerous, he wants to know which admiral won. He transmits the deployment maps and the shot orders, and wants you to determine which admiral won.
    Input

    Input starts with one line, containing the number of test cases t (0 < t ≤ 20).

    Every test case starts with a line, containing three integers w, h and n (1 ≤ w, h ≤ 30; 1 ≤ n ≤ 2000), describing the width and height of the fleet deployment maps, and the number of shots.

    The next h lines contain the deployment map for player one. Each line contains w field descriptions, where '_' means "water" and '#' means "ship". Then follow h lines containing the deployment map for player two.

    The following n lines contain the shot orders; each order consists of two integers, the x and y coordinate of the shot. The x coordinate indicates the column of the shot, running from 0 to w - 1, with 0 meaning the leftmost column. The y coordinate indicates the line of the shot, running from 0 to h - 1, with 0 meaning the last line, and h - 1 meaning the first line of the respective map.

    Please note that there may be more shot orders than needed to end the game.

    Output

    For every test case, print one of "player one wins", "player two wins" or "draw", on a line.

    Sample Input

    2
    4 4 5
    ____
    ____
    #___
    ____
    #___
    ___#
    ____
    ____
    0 0
    1 1
    0 3
    0 2
    0 1
    2 2 5
    _#
    #_
    #_
    #_
    1 0
    0 0
    0 0
    1 1
    0 1

    Sample Output

    player two wins
    draw

    Source

    样例输入

    2
    4 4 5
    ____
    ____
    #___
    ____
    #___
    ___#
    ____
    ____
    0 0
    1 1
    0 3
    0 2
    0 1
    2 2 5
    _#
    #_
    #_
    #_
    1 0
    0 0
    0 0
    1 1
    0 1

    样例输出

    player two wins
    draw

    提示

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部