[蓝桥杯 2024 国 A] 旋转九宫格

Luogu
IDLGP10578
Time3000ms
Memory1024MB
DifficultyP3
搜索2024广度优先搜索 BFS蓝桥杯国赛
给定一个 $3\times 3$ 的九宫格,每个格子内分别含有一个数字,每个格子里的数字互不相同。每步我们可以选择任意一个 $2\times 2$ 的区域将其顺时针旋转,例如: 例如 ```plain 1 2 3 4 5 6 7 8 9 ``` 将其旋转右上角,可得: ```plain 1 5 2 4 6 3 7 8 9 ``` 问最少需要几步才能将给定的状态旋转为 ```plain 1 2 3 4 5 6 7 8 9 ``` ## Input 输入的第一行包含一个整数 $T$ 表示询问的组数。 接下来依次输入每组询问。 每组询问包含三行,每行包含三个数,表示询问的九宫格的状态。 ## Output 输出 $T$ 行,每行包含一个整数表示本次询问的答案。 [samples] ## Note 对于 $60\%$ 的评测用例,$T=1$; 对于所有评测用例,$T\le 10^5$。
Samples
Input #1
2
1 2 3
4 5 6
7 8 9
1 5 2
4 6 3
7 8 9
Output #1
0
3
API Response (JSON)
{
  "problem": {
    "name": "[蓝桥杯 2024 国 A] 旋转九宫格",
    "description": {
      "content": "给定一个 $3\\times 3$ 的九宫格,每个格子内分别含有一个数字,每个格子里的数字互不相同。每步我们可以选择任意一个 $2\\times 2$ 的区域将其顺时针旋转,例如: 例如 ```plain 1 2 3 4 5 6 7 8 9 ``` 将其旋转右上角,可得: ```plain 1 5 2 4 6 3 7 8 9 ``` 问最少需要几步才能将给定的状态旋转为 ```plain ",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 3000,
      "memory_limit": 1048576
    },
    "difficulty": {
      "LuoguStyle": "P3"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP10578"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "给定一个 $3\\times 3$ 的九宫格,每个格子内分别含有一个数字,每个格子里的数字互不相同。每步我们可以选择任意一个 $2\\times 2$ 的区域将其顺时针旋转,例如:\n\n例如\n\n```plain\n1 2 3\n4 5 6\n7 8 9\n```\n\n将其旋转右上角,可得:\n\n```plain\n1 5 2\n4 6 3\n7 8 9\n```\n\n问最少需要几步才能将给定的状态旋转为\n\n```plain\n...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments