304375: CF837B. Flag of Berland

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Flag of Berland

题意翻译

## 题目描述 Berland之旗是满足以下条件的 $n \times m$ 矩形区域: - 旗中包含三种颜色,相应地以字母“R”, “G”和“B”表示。 - 旗中包含三个“长条”,他们的长度和宽度相等(长条1的长度等于长条2的长度,也等于长条3的长度,宽度类似),并且互相平行,同时还平行于旗子的边缘。每个“长条”仅有一种颜色。 - 每个颜色仅能在一个“长条”中出现。 现在给定由“R”, “G”和“B”构成的 $n \times m$ 矩形区域。请判断它是否是一个正确的Berland之旗,是则输出 "YES",否则输出"NO"。 ## 输入输出格式 **输入格式:** 第一行包含两个整数 $n$ 和 $m$ ( $1 \le n, m \le 100 $ )表示区域的大小。 接下来的 $n$ 行表示给定的矩形区域。 **输出格式:** 如果给定的区域是一个正确的Berland之旗则输出"YES"(不含引号),否则输出"NO"(不含引号)。 ## 说明 第三个样例中的区域不包含平行的“长条”。 第四个样例中虽然“长条”间互相平行,且都平行于边缘,但他们高度不同——2,1和1。

题目描述

The flag of Berland is such rectangular field $ n×m $ that satisfies following conditions: - Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. - Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. - Each color should be used in exactly one stripe. You are given a field $ n×m $ , consisting of characters 'R', 'G' and 'B'. Output "YES" (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print "NO" (without quotes).

输入输出格式

输入格式


The first line contains two integer numbers $ n $ and $ m $ ( $ 1<=n,m<=100 $ ) — the sizes of the field. Each of the following $ n $ lines consisting of $ m $ characters 'R', 'G' and 'B' — the description of the field.

输出格式


Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).

输入输出样例

输入样例 #1

6 5
RRRRR
RRRRR
BBBBB
BBBBB
GGGGG
GGGGG

输出样例 #1

YES

输入样例 #2

4 3
BRG
BRG
BRG
BRG

输出样例 #2

YES

输入样例 #3

6 7
RRRGGGG
RRRGGGG
RRRGGGG
RRRBBBB
RRRBBBB
RRRBBBB

输出样例 #3

NO

输入样例 #4

4 4
RRRR
RRRR
BBBB
GGGG

输出样例 #4

NO

说明

The field in the third example doesn't have three parralel stripes. Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.

Input

题意翻译

## 题目描述 Berland之旗是满足以下条件的 $n \times m$ 矩形区域: - 旗中包含三种颜色,相应地以字母“R”, “G”和“B”表示。 - 旗中包含三个“长条”,他们的长度和宽度相等(长条1的长度等于长条2的长度,也等于长条3的长度,宽度类似),并且互相平行,同时还平行于旗子的边缘。每个“长条”仅有一种颜色。 - 每个颜色仅能在一个“长条”中出现。 现在给定由“R”, “G”和“B”构成的 $n \times m$ 矩形区域。请判断它是否是一个正确的Berland之旗,是则输出 "YES",否则输出"NO"。 ## 输入输出格式 **输入格式:** 第一行包含两个整数 $n$ 和 $m$ ( $1 \le n, m \le 100 $ )表示区域的大小。 接下来的 $n$ 行表示给定的矩形区域。 **输出格式:** 如果给定的区域是一个正确的Berland之旗则输出"YES"(不含引号),否则输出"NO"(不含引号)。 ## 说明 第三个样例中的区域不包含平行的“长条”。 第四个样例中虽然“长条”间互相平行,且都平行于边缘,但他们高度不同——2,1和1。

加入题单

算法标签: