2751Rectangular

2751   Rectangular

题目描述

Give you a chessboard. Each grid of it is painted either black or white. Tom wonders whether all black parts can exactly form a non-empty solid rectangular. Could you help him?

输入格式:

      Multiple cases. The number of cases will not exceed 100.

      For each case, the first line contains two integers N (1 ≤ N ≤ 1000) and M (1 ≤ M ≤ 1000), indicating the chessboard’s size. Then following N lines, each line contains M characters, indicating the colors of the corresponding grids. ’w’ means white and ‘b’ means black.

输出格式:

For each case, if all black parts can exactly form a rectangular, print ‘Yes’, otherwise print ‘No’.
输入样例 复制
5 5
wwwww
wbbbw
wbbbw
wbbbw
wwwww
5 5
wwwww
wbbbw
wbwbw
wbbbw
wwwww
输出样例 复制
Yes
No

说明

9
27
通过提交
时空限制2000ms/32mb
题目来源
评测方式在线评测
题目类型
难        度