QOJ.ac

QOJ

実行時間制限: 2.0 s メモリ制限: 256 MB 満点: 100

#11539. 网格与数字游戏

統計

Busy Beaver 和 Calico Bear 正在玩一个游戏,游戏使用一个 $N$ 行 $M$ 列的非负整数网格 $a_{i,j}$,初始时,网格中任意两个相邻的数字都不相等。

在每一轮中,玩家选择网格中的一个正整数并将其减 $1$,前提是操作后网格仍需满足任意两个相邻数字不相等,且所有数字均为非负整数。如果一名玩家在轮到自己时无法进行合法操作,则该玩家输掉比赛,另一名玩家获胜。

Busy Beaver 先手,随后双方轮流操作。假设双方均采取最优策略,请判断 Busy Beaver 是否拥有必胜策略。

输入格式

每个测试点包含多个测试用例。第一行包含一个整数 $T$ ($1 \leq T \leq 10^4$),表示测试用例的数量。每个测试用例的描述如下:

每个测试用例的第一行包含两个正整数 $N$ 和 $M$ ($1 \leq N, M, N \cdot M \leq 2.5 \cdot 10^5$),表示网格的维度。

接下来的 $N$ 行中,第 $i$ 行包含 $M$ 个空格分隔的非负整数 $a_{i,1}, \dots, a_{i,M}$ ($0 \leq a_{i,j} \leq 10^9$),其中 $a_{i,j}$ 表示网格中第 $i$ 行第 $j$ 列的整数。

所有测试用例的 $N \cdot M$ 之和不超过 $2.5 \cdot 10^5$。

输出格式

对于每个测试用例,如果 Busy Beaver 获胜,输出 “YES”;如果 Calico Bear 获胜,输出 “NO”。

输出时大小写不敏感(例如,“yES”、“yes” 和 “Yes” 均会被识别为肯定回答)。

子任务

本题有两个子任务:

  • ($20$ 分) $0 \leq a_{i,j} \leq 100$。
  • ($80$ 分) 无附加限制。

样例

输入 1

5
1 1
1
1 5
0 1 2 3 4
3 3
0 1 0
10 3 10
0 1 0
2 4
0 2 4 6
1 3 5 7
4 5
6 7 6 7 6
7 6 7 6 7
6 7 6 7 6
7 6 7 6 7

输出 1

Yes
No
Yes
No
No

说明

在第一个测试用例中,Busy Beaver 可以将 $1$ 减为 $0$。此时 Calico Bear 没有合法操作,因此 Busy Beaver 拥有必胜策略。

在第二个测试用例中,Busy Beaver 没有合法操作。因此 Calico Bear 拥有必胜策略。

在第三个测试用例中,Busy Beaver 首先将中间的 $3$ 减为 $2$。随后,无论 Calico Bear 减小哪一个 $10$,Busy Beaver 都可以减小另一个 $10$。因此,Calico Bear 会比 Busy Beaver 先耗尽操作次数,从而使 Busy Beaver 拥有必胜策略。

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.