QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 128 MB مجموع النقاط: 100

#3695. 集成电路

الإحصائيات

Bytel 公司正在开发一种新的集成电路,它包含 $n \cdot m$ 个内存芯片,排列在 $n$ 行 $m$ 列中。第 $i$ 行第 $j$ 列的芯片($1 \le i \le n, 1 \le j \le m$)坐标为 $(i, j)$。

位于左上角坐标为 $(1, 1)$ 的芯片已接通电源。为了给其余芯片供电,还需要建立 $nm - 1$ 条连接。具体来说,每个芯片都应连接到其左、右、上或下相邻芯片中的至少一个,以便存在一条从该芯片通往左上角芯片的路径。公司的电气工程师坚持要求连接网络中的最长路径(在某对芯片之间)的长度必须恰好为 $k$,否则量子效应会使电路失效。

请编写一个程序,在存在这样的连接网络时将其找出来。

输入格式

输入的第一行包含三个整数 $n, m$ 和 $k$($n, m \ge 1, 0 \le k \le 1\,000\,000$),分别指定了电路的参数:行数、列数以及所需的最长路径长度。

输出格式

如果不存在具有所需属性的网络,则输出单个单词 NIE(波兰语中的“不”)。

否则,输出 $nm$ 行。第一行输出单词 TAK(波兰语中的“是”),接下来的 $nm - 1$ 行,每行包含四个整数 $i_1, j_1, i_2, j_2$($1 \le i_1, i_2 \le n, 1 \le j_1, j_2 \le m$),用空格分隔,表示网络中包含坐标为 $(i_1, j_1)$ 和 $(i_2, j_2)$ 的芯片之间的连接。

如果存在多个正确的解决方案,程序可以输出其中任意一个。

样例

输入 1

2 3 4

输出 1

TAK
1 1 1 2
1 1 2 1
1 2 2 2
2 3 2 2
1 2 1 3

说明 1

示例说明:图中描绘了 $2 \times 3$ 集成芯片的一个示例连接网络。最长路径连接坐标为 $(2, 1)$ 和 $(2, 3)$ 的芯片,长度为 4。

输入 2

2 3 1

输出 2

NIE

子任务

测试集由以下子任务组成。每个子任务内可能包含多个测试点。 如果你的程序在某个测试点中正确输出了第一行的 TAK,但随后输出了错误的连接方案,你将获得该测试点 20% 的分数。

子任务 条件 分数
1 $n, m \le 6$ 20
2 $n \le 3, m \le 1000$ 20
3 $n, m \le 1000$, 芯片总数为奇数 30
4 $n, m \le 1000$, 芯片总数为偶数 30

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.