CF1797B.Li Hua and Pattern
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Li Hua has a pattern of size n×n, each cell is either blue or red. He can perform exactly k operations. In each operation, he chooses a cell and changes its color from red to blue or from blue to red. Each cell can be chosen as many times as he wants. Is it possible to make the pattern, that matches its rotation by 180∘?
Suppose you were Li Hua, please solve this problem.
李华有一个 n×n 的图案,每个格子为蓝色或红色。他恰好可以执行 k 次操作。每次操作中,他选择一个格子,并将其颜色由红色变为蓝色,或由蓝色变为红色。每个格子可被选中任意多次。能否通过这些操作,使该图案与其绕中心旋转 180∘ 后的图案完全一致?
假设你是李华,请解决此问题。
输入格式
The first line contains the single integer t (1≤t≤100) — the number of test cases.
The first line of each test case contains two integers n,k (1≤n≤103,0≤k≤109) — the size of the pattern and the number of operations.
Each of next n lines contains n integers ai,j (ai,j∈0,1) — the initial color of the cell, 0 for blue and 1 for red.
It's guaranteed that sum of n over all test cases does not exceed 103.
第一行包含一个整数 t(1≤t≤100)—— 测试用例的数量。
每个测试用例的第一行包含两个整数 n,k(1≤n≤103,0≤k≤109)—— 图案的大小和操作次数。
接下来的 n 行,每行包含 n 个整数 ai,j(ai,j∈{0,1})—— 单元格的初始颜色,0 表示蓝色,1 表示红色。
保证所有测试用例的 n 值之和不超过 103。
输出格式
For each set of input, print "YES" if it's possible to make the pattern, that matches its rotation by 180∘ after applying exactly k of operations, and "NO" otherwise.
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
对于每组输入,如果恰好执行 k 次操作后,能够得到一个与其绕中心旋转 180∘ 后的图案完全匹配的图案,则输出 "YES";否则输出 "NO"。
你可以以任意大小写形式输出答案(大写或小写均可)。例如,字符串 "yEs"、"yes"、"Yes" 和 "YES" 均会被识别为肯定回答。
输入输出样例
输入#1
3 4 0 1 1 1 1 0 0 0 1 1 0 1 0 1 1 1 1 4 3 1 0 1 1 1 0 0 0 0 1 0 1 1 1 0 1 5 4 0 0 0 0 0 0 1 1 1 1 0 1 0 0 0 1 1 1 1 1 0 0 0 0 0
输出#1
NO YES YES
说明/提示
In test case 1, you can't perform any operation. The pattern after rotation is on the right.


In test case 2, you can perform operations on (2,1),(3,2),(3,4). The pattern after operations is in the middle and the pattern after rotation is on the right.



在测试用例 1 中,你无法执行任何操作。旋转后的图案位于右侧。


在测试用例 2 中,你可以在位置 (2,1)、(3,2) 和 (3,4) 上执行操作。操作后的图案位于中间,旋转后的图案位于右侧。



输入解题思路,AI测评打分。不知道怎么写?