302455: CF472E. Design Tutorial: Learn from a Game
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Design Tutorial: Learn from a Game
题目描述
One way to create task is to learn from game. You should pick a game and focus on part of the mechanic of that game, then it might be a good task. Let's have a try. Puzzle and Dragon was a popular game in Japan, we focus on the puzzle part of that game, it is a tile-matching puzzle. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF472E/0df1f37c391cc1320e82fbc238d35e416c16ae44.png)(Picture from Wikipedia page: http://en.wikipedia.org/wiki/Puzzle_&_Dragons)There is an $ n×m $ board which consists of orbs. During the game you can do the following move. In the beginning of move you touch a cell of the board, then you can move your finger to one of the adjacent cells (a cell not on the boundary has 8 adjacent cells), then you can move your finger from the current cell to one of the adjacent cells one more time, and so on. Each time you move your finger from a cell to another cell, the orbs in these cells swap with each other. In other words whatever move you make, the orb in the cell you are touching never changes. The goal is to achieve such kind of pattern that the orbs will be cancelled and your monster will attack the enemy, but we don't care about these details. Instead, we will give you the initial board as an input and the target board as an output. Your goal is to determine whether there is a way to reach the target in a single move.输入输出格式
输入格式
One way to create task is to learn from game. You should pick a game and focus on part of the mechanic of that game, then it might be a good task. Let's have a try. Puzzle and Dragon was a popular game in Japan, we focus on the puzzle part of that game, it is a tile-matching puzzle. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF472E/0df1f37c391cc1320e82fbc238d35e416c16ae44.png)(Picture from Wikipedia page: http://en.wikipedia.org/wiki/Puzzle_&_Dragons)There is an $ n×m $ board which consists of orbs. During the game you can do the following move. In the beginning of move you touch a cell of the board, then you can move your finger to one of the adjacent cells (a cell not on the boundary has 8 adjacent cells), then you can move your finger from the current cell to one of the adjacent cells one more time, and so on. Each time you move your finger from a cell to another cell, the orbs in these cells swap with each other. In other words whatever move you make, the orb in the cell you are touching never changes. The goal is to achieve such kind of pattern that the orbs will be cancelled and your monster will attack the enemy, but we don't care about these details. Instead, we will give you the initial board as an input and the target board as an output. Your goal is to determine whether there is a way to reach the target in a single move.
输出格式
One way to create task is to learn from game. You should pick a game and focus on part of the mechanic of that game, then it might be a good task. Let's have a try. Puzzle and Dragon was a popular game in Japan, we focus on the puzzle part of that game, it is a tile-matching puzzle. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF472E/0df1f37c391cc1320e82fbc238d35e416c16ae44.png)(Picture from Wikipedia page: http://en.wikipedia.org/wiki/Puzzle_&_Dragons)There is an $ n×m $ board which consists of orbs. During the game you can do the following move. In the beginning of move you touch a cell of the board, then you can move your finger to one of the adjacent cells (a cell not on the boundary has 8 adjacent cells), then you can move your finger from the current cell to one of the adjacent cells one more time, and so on. Each time you move your finger from a cell to another cell, the orbs in these cells swap with each other. In other words whatever move you make, the orb in the cell you are touching never changes. The goal is to achieve such kind of pattern that the orbs will be cancelled and your monster will attack the enemy, but we don't care about these details. Instead, we will give you the initial board as an input and the target board as an output. Your goal is to determine whether there is a way to reach the target in a single move.
输入输出样例
输入样例 #1
2 2
1 3
2 3
1 3
3 2
输出样例 #1
3
1 1
2 2
2 1
1 1
输入样例 #2
2 2
1 3
2 3
1 2
2 3
输出样例 #2
-1
输入样例 #3
1 4
1 2 3 4
4 3 2 1
输出样例 #3
-1
输入样例 #4
4 1
1
2
3
4
3
1
2
4
输出样例 #4
2
3 1
2 1
1 1