CF1797B.Li Hua and Pattern

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Li Hua has a pattern of size n×nn\times n , each cell is either blue or red. He can perform exactly kk 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 180180^{\circ} ?

Suppose you were Li Hua, please solve this problem.

输入格式

The first line contains the single integer tt ( 1t1001 \le t \le 100 ) — the number of test cases.

The first line of each test case contains two integers n,kn,k ( 1n103,0k1091\le n\le 10^3,0\le k \le 10^9 ) — the size of the pattern and the number of operations.

Each of next nn lines contains nn integers ai,ja_{i,j} ( ai,j{0,1}a_{i,j}\in\{0,1\} ) — the initial color of the cell, 00 for blue and 11 for red.

It's guaranteed that sum of nn over all test cases does not exceed 10310^3 .

输出格式

For each set of input, print "YES" if it's possible to make the pattern, that matches its rotation by 180180^{\circ} after applying exactly kk 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.

输入输出样例

  • 输入#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)(2,1),(3,2),(3,4) . The pattern after operations is in the middle and the pattern after rotation is on the right.

首页