QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 512 MB 總分: 100

#529. 骆驼

统计

我们来定义一种新的“棋子”,称之为“camel-tone”。这种棋子的移动方式是跳跃:水平或垂直跳过两个棋盘格,或者对角线跳过一个棋盘格。下图展示了棋盘的一部分,中间放置了一个 camel-tone,以及它一步可以到达的位置(标记为 x)。当然,它不能跳出棋盘范围,棋盘是一个被划分为 $N \times N$ 个小方格的大正方形。在本题中,$N$ 总是 5 的倍数。

camel-tone 从棋盘左上角的方格开始。游戏过程是在棋盘上进行一系列移动,访问每个方格恰好一次。此外,在进行了 $N^2-1$ 次移动后,棋子应该恰好位于距离起始位置一步之遥的地方。这就是所谓的“camel-tonian 循环”!

任务

编写一个程序 camel 来寻找任何一种可行的游戏方式,或者报告该循环是不可能的。

输入格式

从标准输入读取一行,仅包含一个整数 $N$。

输出格式

程序必须向标准输出写入:

  • 如果确定循环是不可能的,则输出一行 NO
  • 或者输出 $N$ 行,每行包含 $N$ 个空格分隔的数字,这些数字是 $1$ 到 $N^2$ 之间的不同正整数。第一行的第一个数字为 1。输出表示棋盘($N \times N$ 个方格),其中整数表示连续占据的位置。参见下方的样例。

数据范围

  • $N$ 是 5 的倍数
  • $5 \le N \le 1000$

子任务

  • 有一个 $N = 5$ 的测试点,占该任务分数的 20%。
  • 其余 16 个测试点各占 5% 的分数。

样例

输入 1

10

输出 1

1 52 29 8 51 28 9 50 37 16
85 95 59 86 94 66 87 93 65 88
40 19 100 39 18 76 38 17 77 49
2 53 30 7 58 27 10 89 36 15
84 96 60 75 99 67 72 92 64 71
41 20 82 44 23 90 45 24 78 48
3 54 31 6 57 26 11 68 35 14
83 97 61 74 98 62 73 91 63 70
42 21 81 43 22 80 46 25 79 47
4 55 32 5 56 33 12 69 34 13

说明

camel-tone 从左上角位置(第 1 行,第 1 列)开始,编号为 1。第二个占据的位置是(第 4 行,第 1 列),因此编号为 2。下一个位置是(第 7 行,第 1 列),编号为 3,依此类推。最后一个(第 100 个)占据的位置是(第 3 行,第 3 列),它距离起始位置恰好一步之遥。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.