A15669 | Li Hua and Pattern
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Li Hua has a pattern of size $n\times 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^{\circ}$ ?
Suppose you were Li Hua, please solve this problem.
Suppose you were Li Hua, please solve this problem.
输入格式
The first line contains the single integer $t$ ( $1 \le t \le 100$ ) — the number of test cases.
The first line of each test case contains two integers $n,k$ ( $1\le n\le 10^3,0\le k \le 10^9$ ) — the size of the pattern and the number of operations.
Each of next $n$ lines contains $n$ integers $a_{i,j}$ ( $a_{i,j}\in\{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 $10^3$ .
The first line of each test case contains two integers $n,k$ ( $1\le n\le 10^3,0\le k \le 10^9$ ) — the size of the pattern and the number of operations.
Each of next $n$ lines contains $n$ integers $a_{i,j}$ ( $a_{i,j}\in\{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 $10^3$ .
输出格式
For each set of input, print "YES" if it's possible to make the pattern, that matches its rotation by $180^{\circ}$ 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.
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)$ . The pattern after operations is in the middle and 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.

C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted