QOJ.ac

QOJ

Limite de temps : 1.0 s Limite de mémoire : 256 MB Points totaux : 100 Hackable ✓

#8830. 绝命毒师

Statistiques

Walter White 终于走上了不归路,并建立起了他的毒品帝国。

现在生意场上有 5 个人:Walt、Jesse、Mike、Saul 和 Todd。他们将 Albuquerque 划分成了 $n \times n$ 个区域,并计算出第 $i$ 行第 $j$ 列交叉区域的收益为 $a_{i,j}$ 美元。

他们想要选择 $n$ 个区域来收取钱财。为了不引起 Hank 的怀疑,他们要求每一行和每一列都恰好选中一个区域。如果这些区域的总收益为 $S$,他们会将这笔钱平分给这 5 个人,并将剩余的 $S \pmod 5$ 美元捐赠给 Ted Beneke。

请找出所有可能捐赠给 Ted Beneke 的金额。

输入格式

第一行包含一个正整数 $n$ ($1 \le n \le 10^3$),表示网格的大小。

接下来的 $n$ 行,每行包含 $n$ 个整数 $a_{i,j}$ ($0 \le a_{i,j} \le 4$),表示第 $i$ 行第 $j$ 列交叉区域的收益。

输出格式

输出一个长度恰好为 5 的字符串,由字母 Y 或 N 组成。如果可能得到的总收益满足 $S \equiv i \pmod 5$(其中 $0 \le i < 5$),则字符串的第 $i$ 个字符必须为 Y,否则为 N。

样例

样例输入 1

2
0 4
4 0

样例输出 1

YNNYN

样例输入 2

2
1 1
1 1

样例输出 2

NNYNN

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.