HDU 5601 N*M bulbs
来源:互联网 发布:神马快递单打印软件 编辑:程序博客网 时间:2024/05/18 12:43
Problem Description
N*M bulbs are in a rectangle, some are on, and some are off.
in order to save electricity, you should turn off all the lights, but you're lazy.
coincidentally,a passing bear children paper(bear children paper means the naughty boy), who want to pass here from the top left light bulb to the bottom right one and leave.
he starts from the top left light and just can get to the adjacent one in one step.
But after all,the bear children paper is just a bear children paper. after leaving a light bulb to the next one, he must touch the switch, which will change the status of the light.
your task is answer whether it's possible or not to finishing turning off all the lights, and make bear children paper also reach the bottom right light bulb and then leave at the same time.
in order to save electricity, you should turn off all the lights, but you're lazy.
coincidentally,a passing bear children paper(bear children paper means the naughty boy), who want to pass here from the top left light bulb to the bottom right one and leave.
he starts from the top left light and just can get to the adjacent one in one step.
But after all,the bear children paper is just a bear children paper. after leaving a light bulb to the next one, he must touch the switch, which will change the status of the light.
your task is answer whether it's possible or not to finishing turning off all the lights, and make bear children paper also reach the bottom right light bulb and then leave at the same time.
Input
The first line of the input file contains an integer T, which indicates the number of test cases.
For each test case, there are n+1 lines.
The first line of each test case contains 2 integers n,m.
In the following n line contains a 01 square, 0 means off and 1 means on.
*T≤10
*N,M≤1000
For each test case, there are n+1 lines.
The first line of each test case contains 2 integers n,m.
In the following n line contains a 01 square, 0 means off and 1 means on.
*
*
Output
There should be exactly T lines in the output file.
The i-th line should only contain "YES" or "NO" to answer if it's possible to finish.
The i-th line should only contain "YES" or "NO" to answer if it's possible to finish.
Sample Input
11 51 0 0 0 0
Sample Output
YESHintChild's path is: (1,1)(1,2)(1,3)(1,2)(1,3)(1,4)(1,5)(4,5)all switches are touched twice except the first one.从左上角下去能改变的灯数和一开始亮着的灯数之间要满足这种关系才能到达
#include<map>#include<cstdio>#include<vector>#include<cstring>#include<iostream>#include<algorithm>#include<functional>using namespace std;typedef long long LL;const int maxn = 1e5 + 10;int T, n, m, x, sum;int main(){ scanf("%d", &T); while (T--) { scanf("%d%d", &n, &m); sum = 0; for (int i = 0; i < n;i++) for (int j = 0; j < m; j++) { scanf("%d", &x); sum += x; } if ((n + m + sum) % 2 == 1) printf("YES\n"); else printf("NO\n"); } return 0;}
0 0
- HDU 5601:N*M bulbs
- hdu 5601 N*M bulbs
- HDU 5601 N*M bulbs
- HDU 5601 N*M bulbs
- hdu 5601 N*M bulbs(规律)
- hdu 5601 N*M bulbs 找规律
- HDU 5601 N*M bulbs 乱搞
- HDU 5601 N*M bulbs(机智)
- HDU-5601 N*M bulbs(推导||规律)
- HDU -- 5601 N*M bulbs 【思维 + 规律】
- hdu 5601(5600) /BC 67B(A) N*M bulbs
- hdu 5601 N*M bulbs(找规律)
- hdoj N*M bulbs 5601 (规律)
- 杭电5601 N*M bulbs
- hdu5601 N*M bulbs
- HDU5601:N*M bulbs
- hdu 5600 N bulbs
- HDU 5600:N bulbs
- Spark学习笔记5-隐式转换,隐式参数,隐式类
- 第十章编程练习(3)
- 在Mac系统下安装mongodb两种方式
- 安卓项目中 一些常见 API接口总结
- POJ 2533 3903(最长递增子序列)
- HDU 5601 N*M bulbs
- 微信支付错误两个问题的解决:curl出错,错误码:60
- java替换pdf模板出现中文乱码问题
- HDU 5606 tree
- django学习心得
- C++引用计数(reference counting)技术简介(3)
- Number Sequence
- Json 中对Key为空的判断
- HDU 5605 geometry