21070_BlockGame

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

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

Pro.ID

21070

Title

Block Game

Title链接

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

AC

2

Submit

598

Ratio

0.33%

时间&空间限制

  • Time Limit: 15000/5000 MS (Java/Others)     Memory Limit: 131072/65536 K (Java/Others)
  • 描述

    Bud bought this new board game. He is hooked. He has been playing it over and over again such that he thinks can finish the game with the minimum number of moves, but he is uncertain. He wants you to help him check whether the moves he has listed are indeed the minimum number of moves.


    You are given a 6x6 board, and a set of 2x1 or 3x1 (vertical) or 1x2 or 1x3 (horizontal) pieces. You can slide the horizontal pieces horizontally only, and the vertical pieces vertically only. You are only allowed to slide a piece if there is no other piece, nor a wall, obstructing its path.

    There will be one special 1x2 horizontal piece. There will also be a gap in the wall, on the right side, on the same row as the special piece, that only the special piece can fit through. The goal of the game is to get that one special horizontal piece out of the gap on the right side.

    A “move” in this game is when you take a piece and slide it any number of squares (i.e. if you slide a piece horizontally one square, that is one move, and sliding it 2 squares at once is also considered one move).

    输入

    Input will consist of multiple datasets. Each data set will begin with a line with a single capital letter, indicating the special piece which must move off of the board.
    The next 6 lines will consist of 6 characters each. These characters will either be a ’.’ (period), indicating an empty square, or a capital letter, indicating part of a piece.
    The letters are guaranteed to form pieces that are 1x2, 1x3, 2x1 or 3x1, and no letter will be used to represent more than one piece on any given board. The letter indicating the special piece is guaranteed to correspond to a 1x2 piece somewhere on the board.
    The end of data is indicated by a single ’*’ (asterisk) on its own line.

    输出

    Description

    Bud bought this new board game. He is hooked. He has been playing it over and over again such that he thinks can finish the game with the minimum number of moves, but he is uncertain. He wants you to help him check whether the moves he has listed are indeed the minimum number of moves.


    You are given a 6x6 board, and a set of 2x1 or 3x1 (vertical) or 1x2 or 1x3 (horizontal) pieces. You can slide the horizontal pieces horizontally only, and the vertical pieces vertically only. You are only allowed to slide a piece if there is no other piece, nor a wall, obstructing its path.

    There will be one special 1x2 horizontal piece. There will also be a gap in the wall, on the right side, on the same row as the special piece, that only the special piece can fit through. The goal of the game is to get that one special horizontal piece out of the gap on the right side.

    A “move” in this game is when you take a piece and slide it any number of squares (i.e. if you slide a piece horizontally one square, that is one move, and sliding it 2 squares at once is also considered one move).

    Input
    Input will consist of multiple datasets. Each data set will begin with a line with a single capital letter, indicating the special piece which must move off of the board.
    The next 6 lines will consist of 6 characters each. These characters will either be a ’.’ (period), indicating an empty square, or a capital letter, indicating part of a piece.
    The letters are guaranteed to form pieces that are 1x2, 1x3, 2x1 or 3x1, and no letter will be used to represent more than one piece on any given board. The letter indicating the special piece is guaranteed to correspond to a 1x2 piece somewhere on the board.
    The end of data is indicated by a single ’*’ (asterisk) on its own line.
    Output
    For each data set, print a single integer, indicating the smallest number of moves necessary to remove the given piece, or -1 if it isn’t possible. Print each integer on its own line. There should be no blank lines between outputs.
    Sample Input
    C
    ..AB..
    ..AB..
    CCAB..
    ......
    .DDEE.
    ......
    A
    ......
    ......
    ......
    ......
    AA....
    ......
    Z
    .ZZ..X
    .....X
    .....X
    .....Y
    .....Y
    .....Y
    *
    Sample Output
    5
    1
    -1
    Source

    样例输入

    C
    ..AB..
    ..AB..
    CCAB..
    ......
    .DDEE.
    ......
    A
    ......
    ......
    ......
    ......
    AA....
    ......
    Z
    .ZZ..X
    .....X
    .....X
    .....Y
    .....Y
    .....Y
    *

    样例输出

    5
    1
    -1

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部