22156_NineDigits

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

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

Pro.ID

22156

Title

Nine Digits

Title链接

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

AC

4

Submit

20

Ratio

20.00%

时间&空间限制

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

    Nine tiles, each with a number from 1 to 9 on it, are packed into a 3 by 3 frame. Your task is to arrange the tiles so that they are ordered as:

    1 2 3
    4 5 6
    7 8 9

    At each step, you can do the following operation to the tiles: Choose 2 by 2 tiles, rotate the tiles in clockwise order. For example:

    1 2 3    4 1 3       1 2 3    1 2 3
    4 5 6 => 5 2 6   or  4 5 6 => 4 8 5
    7 8 9    7 8 9       7 8 9    7 9 6

    Write a program to find the minimum number of steps.

    输入

    Input contains multiple test cases.

    Each test case is a description of a configuration of the nine tiles. The description is just a list of the tiles in their initial positions, with the rows listed from top to bottom, and from left to right within a row, where the tiles are represented by numbers 1 to 9. For example:

    9 8 7
    6 5 4
    3 2 1

    is described by this list:

    9 8 7 6 5 4 3 2 1

    输出

    Description

    Nine tiles, each with a number from 1 to 9 on it, are packed into a 3 by 3 frame. Your task is to arrange the tiles so that they are ordered as:

    1 2 3
    4 5 6
    7 8 9

    At each step, you can do the following operation to the tiles: Choose 2 by 2 tiles, rotate the tiles in clockwise order. For example:

    1 2 3    4 1 3       1 2 3    1 2 3
    4 5 6 => 5 2 6   or  4 5 6 => 4 8 5
    7 8 9    7 8 9       7 8 9    7 9 6

    Write a program to find the minimum number of steps.

    Input

    Input contains multiple test cases.

    Each test case is a description of a configuration of the nine tiles. The description is just a list of the tiles in their initial positions, with the rows listed from top to bottom, and from left to right within a row, where the tiles are represented by numbers 1 to 9. For example:

    9 8 7
    6 5 4
    3 2 1

    is described by this list:

    9 8 7 6 5 4 3 2 1

    Output

    Output the minimum number of steps on a single line for each test case.

    Sample Input

    1 2 3 4 5 6 7 8 9
    4 1 3 5 2 6 7 8 9

    Sample Output

    0
    3

    Source

    样例输入

    1 2 3 4 5 6 7 8 9
    4 1 3 5 2 6 7 8 9

    样例输出

    0
    3

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部