A. Flag

Source: Internet
Author: User
Time limit per test

2 seconds

Memory limit per test

64 megabytes

Input

Standard Input

Output

Standard output

According to a new ISO standard, a flag of every country shoshould have a chequered FieldNLimit × limitM, Each square shocould be of one of 10
Colours, and the flag shocould be «striped»: each horizontal row of the Flag shoshould contain squares of the same color, and the colours of adjacent horizontal rows shocould be different. berland's government asked you to find out whether their flag meets the new
ISO standard.

Input

The first line of the input contains numbersN And M ( 1 bytes ≤ bytesN, Bytes,MLimit ≤ limit 100 ), N -
The amount of rows, M -The amount of columns on the flag of berland. Then there follows the description of the flag: Each of the followingN Lines
Contain M Characters. Each character is a digit 0 And 9 ,
And stands for the color of the corresponding square.

Output

OutputYes, If the flag meets the new ISO standard, andNoOtherwise.

Sample test (s) Input
 
3 3000111222
Output
Yes
Input
 
3 3000000111
Output
No
Input
 
3 3000111002
Output
No

Explanation: This is to judge whether a row of numbers is exactly the same, and the numbers of two adjacent lines are different.

 
# Include <iostream> # include <cstdio> using namespace STD; int main () {int n, m, I, j; char C; int flag = 0; char A [101] [101]; scanf ("% d", & N, & M); for (I = 0; I <n; I ++) {for (j = 0; j <m; j ++) {CIN> A [I] [J] ;}} for (I = 0; I <N; I ++) {c = A [I] [0]; for (j = 1; j <m; j ++) {if (a [I] [J]! = C) {flag = 1; break;} If (flag = 1) {break;} for (I = 0; I <n-1; I ++) {if (a [I] [0] = A [I + 1] [0]) {flag = 1; break ;}} if (flag = 1) {printf ("NO \ n");} else {printf ("Yes \ n");} return 0 ;}

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.