Bestcoder Round #67 (Div.2) n*m Bulbs

Source: Internet
Author: User

Problem Description
N*m a light bulb in a row, that is, a n*m of the rectangle, some open, some closed, in order to save electricity, you have to close all the lights, but you are very lazy. Just a bear boy was passing by, and he just went from the light bulb in the upper left corner to the light bulb in the lower right corner and left. But after all, bear child paper, bear child paper before leaving a light bulb, will definitely move the current switch, that is, open the change off, off the change. It is impossible to ask you to close all the lights, while the bear can also reach the lower right corner of the light bulb, and then leave.
Enter a description
 The first line T, which represents the T group data. Next T Group data: Each set of data, the first row of N,m, followed by a n*m 01 matrix, indicating the initial switch state of the bulb, 0 for the off, 1 for the open. 1 \leq T \leq 101≤t≤101 \leq N, M \leq 10001≤n ,m≤10< Span class= "Mord" >00            
Output Description
Each set of data, if you can output "YES", otherwise output "NO".
Input Sample
11 51 0 0 0 0
Output Sample
YES
Hint
The child's path is: 123234545 except for the first lamp, the other lights are only passed through even several times.

The total number of operations is the same as n-n parity. If the sum of 1 is different from the parity of N, there is no solution, and if the parity is the same, there is a solution.

1#include <iostream>2#include <cstdio>3 intT,n,count,a;4 intMainintargcChar**argv)5 {6scanf"%d",&t);7      while(t--)8     {9scanf"%d",&n);TenCount=0; One          for(intI=0; i<n;i++) A         { -scanf"%d",&a); -             if(a==1) count++; the         } -         if(count%2==0&&n%2==0|| count%2!=0&&n%2!=0) -printf"yes\n"); -         Else +printf"no\n"); -     } +     return 0; A}

Bestcoder Round #67 (Div.2) n*m Bulbs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.