21012_PegGame

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

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

Pro.ID

21012

Title

Peg Game

Title链接

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

AC

0

Submit

851

Ratio

0.00%

时间&空间限制

  • Time Limit: 1500/500 MS (Java/Others)     Memory Limit: 20000/10000 K (Java/Others)
  • 描述

    You are given a 7-by-7 board of holes. Some holes are filled with pegs, and some are not. You may jump a peg over an adjacent peg, as long as the hole the jumping peg lands in is unoccupied. The jumped peg is removed. Your goal is to leave the board with only one peg in it, and the peg must end up in the specified location. 
    The board is specified as a 7-by-7 array of characters, with the following meanings: 
    x : this hole may never be occupied by a peg 
    e : this hole is initially empty 
    o : this hole is initially occupied by a peg 
    E : this hole is initially empty, and the last peg should end here 
    O : this hole is initially occupied, and the last peg should end here 
    For example, consider the following board: 
    x x e e e x x 
    x x o e e x x 
    e e o e e e e 
    e e o O e e e 
    e e e e e e e 
    x x e e e x x 
    x x e e e x x 
    You can see that there are initially 4 pegs in the board, and the last peg should end up in the middle of the board. 
    The winning sequence of moves is: 
    1. (4, 4) to (2, 4) 
    2. (3, 2) to (3, 4) 
    3. (2, 4) to (4, 4) 
    Where coordinates are given as (x, y).

    输入

    The first line of input is the number of datasets to follow. Each dataset should be processed the same. 
    The input for each dataset consists of 7 lines; each line consists of 7 characters from the set {x, e, o, E, O} with blanks between them. You are guaranteed that exactly one 'E' or 'O' will appear, and that two or more 'o' or 'O' will appear.

    输出

    Description
    You are given a 7-by-7 board of holes. Some holes are filled with pegs, and some are not. You may jump a peg over an adjacent peg, as long as the hole the jumping peg lands in is unoccupied. The jumped peg is removed. Your goal is to leave the board with only one peg in it, and the peg must end up in the specified location. 
    The board is specified as a 7-by-7 array of characters, with the following meanings: 
    x : this hole may never be occupied by a peg 
    e : this hole is initially empty 
    o : this hole is initially occupied by a peg 
    E : this hole is initially empty, and the last peg should end here 
    O : this hole is initially occupied, and the last peg should end here 
    For example, consider the following board: 
    x x e e e x x 
    x x o e e x x 
    e e o e e e e 
    e e o O e e e 
    e e e e e e e 
    x x e e e x x 
    x x e e e x x 
    You can see that there are initially 4 pegs in the board, and the last peg should end up in the middle of the board. 
    The winning sequence of moves is: 
    1. (4, 4) to (2, 4) 
    2. (3, 2) to (3, 4) 
    3. (2, 4) to (4, 4) 
    Where coordinates are given as (x, y).
    Input
    The first line of input is the number of datasets to follow. Each dataset should be processed the same. 
    The input for each dataset consists of 7 lines; each line consists of 7 characters from the set {x, e, o, E, O} with blanks between them. You are guaranteed that exactly one 'E' or 'O' will appear, and that two or more 'o' or 'O' will appear.
    Output
    For each dataset, output a line containing the data set number. If a sequence of valid moves exists that leaves only one peg on the board, and leaves that peg in the desired location, print out the sequence of moves, as shown in the above example. If no sequence exists, print "No solution". Leave a blank line between datasets.
    Sample Input
    2
    x x e e e x x
    x x o e e x x
    e e o e e e e
    e e o O e e e
    e e e e e e e
    x x e e e x x
    x x e e e x x
    x x e E e e e
    x e e e e e e
    e e e o o e e
    e e e x e e e
    e e e e e e e
    e e e e e e e
    e e e e e e e
    Sample Output
    Dataset 1:
    1. (4, 4) to (2, 4)
    2. (3, 2) to (3, 4)
    3. (2, 4) to (4, 4)
    
    Dataset 2:
    No solution.
    Hint
    Search order : up, left, down, right
    Source

    样例输入

    2
    x x e e e x x
    x x o e e x x
    e e o e e e e
    e e o O e e e
    e e e e e e e
    x x e e e x x
    x x e e e x x
    x x e E e e e
    x e e e e e e
    e e e o o e e
    e e e x e e e
    e e e e e e e
    e e e e e e e
    e e e e e e e

    样例输出

    Dataset 1:
    1. (4, 4) to (2, 4)
    2. (3, 2) to (3, 4)
    3. (2, 4) to (4, 4)
    
    Dataset 2:
    No solution.

    提示

    Search order : up, left, down, right


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部