Flag

TimeLimit:2000MS  MemoryLimit:64MB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description

According to a new ISO standard, a flag of every country should have a chequered field n × m, each square should be of one of 10 colours, and the flag should be «striped»: each horizontal row of the flag should contain squares of the same colour, and the colours of adjacent horizontal rows should 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 numbers n and m (1 ≤ n, m ≤ 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 following n lines contain m characters. Each character is a digit between 0 and 9, and stands for the colour of the corresponding square.

Output

Output YES, if the flag meets the new ISO standard, and NO otherwise.

SampleInput 1
3 3
000
111
222
SampleOutput 1
YES
SampleInput 2
3 3
000
000
111
SampleOutput 2
NO
SampleInput 3
3 3
000
111
002
SampleOutput 3
NO
Submit
题目统计信息详细
总AC数41
通过人数40
尝试人数40
总提交量58
AC率68.97%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: