10190_ShuttlePuzzle

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

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

Pro.ID

10190

Title

Shuttle Puzzle

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 600/300 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    The Shuttle Puzzle of size 3 consists of 3 white marbles, 3 black marbles, and a strip of wood with 7 holes. The marbles of the same color are placed in the holes at the opposite ends of the strip, leaving the center hole empty.

    INITIAL STATE: WWW_BBB
       GOAL STATE: BBB_WWW

    To solve the shuttle puzzle, use only two types of moves. Move 1 marble 1 space (into the empty hole) or jump 1 marble over 1 marble of the opposite color (into the empty hole). You may not back up, and you may not jump over 2 marbles.

    A Shuttle Puzzle of size N consists of N white marbles and N black marbles and 2N+1 holes.

    Here's one solution for the problem of size 3 showing the initial, intermediate, and end states:

    WWW BBB
    WW WBBB
    WWBW BB
    WWBWB B
    WWB BWB
    W BWBWB
    WBWBWB
    BW WBWB
    BWBW WB
    BWBWBW
    BWBWB W
    BWB BWW
    B BWBWW
    BB WBWW
    BBBW WW
    BBB WWW

    Write a program that will solve the SHUTTLE PUZZLE for any size N (1 ≤ N ≤ 12) in the minimum number of moves and display the successive moves, 20 per line.

    输入

    Multiple test cases. For each case is a single line with the integer N.

    输出

    Description

    The Shuttle Puzzle of size 3 consists of 3 white marbles, 3 black marbles, and a strip of wood with 7 holes. The marbles of the same color are placed in the holes at the opposite ends of the strip, leaving the center hole empty.

    INITIAL STATE: WWW_BBB
       GOAL STATE: BBB_WWW

    To solve the shuttle puzzle, use only two types of moves. Move 1 marble 1 space (into the empty hole) or jump 1 marble over 1 marble of the opposite color (into the empty hole). You may not back up, and you may not jump over 2 marbles.

    A Shuttle Puzzle of size N consists of N white marbles and N black marbles and 2N+1 holes.

    Here's one solution for the problem of size 3 showing the initial, intermediate, and end states:

    WWW BBB
    WW WBBB
    WWBW BB
    WWBWB B
    WWB BWB
    W BWBWB
    WBWBWB
    BW WBWB
    BWBW WB
    BWBWBW
    BWBWB W
    BWB BWW
    B BWBWW
    BB WBWW
    BBBW WW
    BBB WWW

    Write a program that will solve the SHUTTLE PUZZLE for any size N (1 ≤ N ≤ 12) in the minimum number of moves and display the successive moves, 20 per line.

    Input

    Multiple test cases. For each case is a single line with the integer N.

    Output

    For each case:

    The list of moves expressed as space-separated integers, 20 per line (except possibly the last line). Number the marbles/holes from the left, starting with one.

    Output the the solution that would appear first among the set of minimal solutions sorted numerically (first by the first number, using the second number for ties, and so on).

    Output a blank line after each case.

    Sample Input

    3

    Sample Output

    3 5 6 4 2 1 3 5 7 6 4 2 3 5 4

    Source

    样例输入

    3

    样例输出

    3 5 6 4 2 1 3 5 7 6 4 2 3 5 4

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部