QOJ.ac

QOJ

时间限制: 3.0 s 内存限制: 1024 MB 总分: 100 可 Hack ✓

#17809. 消逝

统计

灵乌路空(Reiuji Utsuho)和博丽灵梦(Hakurei Reimu)决定进行一场对决,看看谁的能力更胜一筹。

她们的对决在一个大小为 $(N + 2) \times (N + 2)$ 的网格上进行。列从左到右依次编号为 $0$ 到 $N + 1$,行从上到下依次编号为 $0$ 到 $N + 1$。第 $i$ 行第 $j$ 列的单元格表示为 $(i, j)$。

阿空可以使用她的能力在网格的某些单元格中引发爆炸。她可以选择的单元格数量没有限制,但爆炸只允许在内部的 $N \times N$ 个单元格中发生。更具体地说,如果爆炸发生在单元格 $(i, j)$,则其行和列索引必须满足 $1 \le i, j \le N$。

独特的是,阿空在这场战斗中使用的爆炸非常特殊——它们的破坏力随着单元格距离爆炸源的增加而变强。形式化地,单元格 $(x, y)$ 从发生在 $(i, j)$ 的单次爆炸中受到的伤害定义为 $\max(|x - i|, |y - j|)$。如果发生多次爆炸,则 $(x, y)$ 受到的总伤害是所有爆炸贡献的总和。

在阿空释放力量之前,灵梦使用了她的预知能力。她成功预知了在所有爆炸发生后,网格上每个单元格将受到的总伤害。凭借这些信息,她希望能够精准定位阿空爆炸的具体位置并提前阻止它们。然而,她的预知只显示了伤害值,而没有显示爆炸的具体源头。

给定所有单元格的总伤害值,请找到任意一组能够解释灵梦预知结果的有效爆炸位置。

输入格式

第一行包含一个整数 $N$。

接下来的 $N + 2$ 行,每行包含 $N + 2$ 个由空格分隔的非负整数。接下来的第 $i$ 行中的第 $j$ 个整数表示单元格 $(i - 1, j - 1)$ 的总伤害值,其中行和列的编号为 $0$ 到 $N + 1$,如上所述。

输出格式

输出共 $N$ 行,每行包含 $N$ 个由空格分隔的整数。每个整数必须为 $0$ 或 $1$。如果第 $i$ 行第 $j$ 列的整数为 $1$,则表示计划在单元格 $(i - 1, j - 1)$ 处发生一次爆炸。如果为 $0$,则表示在单元格 $(i - 1, j - 1)$ 处不发生爆炸。

如果存在多种可能的爆炸方案,输出其中任意一种即可。保证至少存在一种可能的爆炸方案。

数据范围

  • $1 \le N \le 1\,000$

样例

输入样例 1

3
2 2 2 2 2
2 1 1 1 2
2 1 0 1 2
2 1 1 1 2
2 2 2 2 2

输出样例 1

0 0 0
0 1 0
0 0 0

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.