| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 40 | 5 | 5 | 41.667% |
In this puzzle, you are given a 0ドル$-indexed $N \times N$ square grid consisting of distinct integers from 0ドル$ to $N \times N - 1,ドル inclusive. Your goal is to reach the ordered state where the number at the intersection of the $i$-th row and the $j$-th column is equal to $i \times N + j$ for each 0ドル ≤ i, j < N$. You can achieve this goal using two types of moves:
Rearrangement refers to changing the order of the numbers without adding or removing any of them, and it may preserve the original order.
For example, if the current grid is:
| Row/Column | 0ドル$ | 1ドル$ | 2ドル$ |
|---|---|---|---|
| 0ドル$ | 2ドル$ | 4ドル$ | 6ドル$ |
| 1ドル$ | 8ドル$ | 1ドル$ | 5ドル$ |
| 2ドル$ | 7ドル$ | 3ドル$ | 0ドル$ |
By performing the move "D 6ドル$ 2ドル$ 4ドル$", we will obtain the following grid:
| Row/Column | 0ドル$ | 1ドル$ | 2ドル$ |
|---|---|---|---|
| 0ドル$ | 8ドル$ | 1ドル$ | 5ドル$ |
| 1ドル$ | 7ドル$ | 3ドル$ | 0ドル$ |
| 2ドル$ | 6ドル$ | 2ドル$ | 4ドル$ |
However, if we instead execute move "R 2ドル$ 8ドル$ 7ドル$", we would get:
| Row/Column | 0ドル$ | 1ドル$ | 2ドル$ |
|---|---|---|---|
| 0ドル$ | 4ドル$ | 6ドル$ | 2ドル$ |
| 1ドル$ | 1ドル$ | 5ドル$ | 8ドル$ |
| 2ドル$ | 3ドル$ | 0ドル$ | 7ドル$ |
For $N = 3,ドル the target grid would look like this:
| Row/Column | 0ドル$ | 1ドル$ | 2ドル$ |
|---|---|---|---|
| 0ドル$ | 0ドル$ | 1ドル$ | 2ドル$ |
| 1ドル$ | 3ドル$ | 4ドル$ | 5ドル$ |
| 2ドル$ | 6ドル$ | 7ドル$ | 8ドル$ |
You aim to solve the puzzle with fewer than 3ドル \times N$ moves. However, partial points may be awarded in case you use more moves or not solve the puzzle. Refer to the scoring section for details.
The first line contains a single integer: $N$.
The following $N$ lines describe the initial grid, with $N$ numbers on each line.
The first line should contain a single integer, $M,ドル the number of moves. Each of the following $M$ lines should contain a single move.
Let’s denote $M$ as the amount of moves in your solution. Additionally, define $A = 3 \times N$ and $B = 2 \times N^2$.
If your output is invalid, or if $M > B,ドル you receive 0ドル$ points. Otherwise, your score depends on the amount of numbers in the correct target positions (denoted as $C$).
If $C < N \times N$ the puzzle is not solved and you will only receive $\left(50 \times \frac{C}{N \times N} \right)\%$ of points for a test. Otherwise:
Each individual test is worth the same number of points. Your score is the sum of individual test scores, and your final score will be the best score among all submissions.
3 1 4 2 3 7 5 6 8 0
4 R 3 6 1 D 2 3 4 D 5 6 7 R 2 5 8
2 2 1 0 3
0