QOJ.ac

QOJ

时间限制: 1.0 s 内存限制: 512 MB 总分: 100

#8485. 幻方

统计

在一个遥远的魔法王国里,住着一位著名的巫师梅林。他以其神奇的能力和制造魔法物品的技巧而闻名。有一天,梅林创造了一个大小为 $n \times n$ 的幻方,每个单元格中包含一个从 $1$ 到 $n^2$ 的整数,且所有数字各不相同。这个幻方具有神奇的特性:所有行和所有列的数字之和都相等。

然而,有一天,当梅林稍不留神时,邪恶的巫师格格巫潜入了他的实验室,决定搞破坏。他交换了幻方中的两个数字,希望能破坏它的魔法力量。

现在,梅林需要你的帮助来确定哪两个数字被交换了。

输入格式

第一行包含一个整数 $n$ ($3 \le n \le 1000$),表示幻方的大小。接下来的 $n$ 行中,每行包含 $n$ 个数字 $a_{ij}$ ($1 \le a_{ij} \le n^2$)。保证所有数字各不相同。保证存在两个数字,交换它们后可以使该方阵重新成为幻方。

输出格式

你需要输出四个数字 $r_1, c_1, r_2$ 和 $c_2$,分别表示需要交换的第一个数字的行号和列号,以及第二个数字的行号和列号。行号和列号均从 $1$ 开始编号,分别从上到下和从左到右计数。

样例

输入 1

3
6 9 2
3 5 7
8 1 4

输出 1

1 1 3 3

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.