codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

837B.md (1689B)


      1 Source: https://codeforces.com/problemset/problem/837/B
      2 
      3 B. Flag of Berland
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 The flag of Berland is such rectangular field *n* × *m* that satisfies following conditions:
     22 
     23 * Flag consists of three colors which correspond to letters 'R', 'G' and 'B'.
     24 * 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.
     25 * Each color should be used in exactly one stripe.
     26 
     27 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).
     28 
     29 Input
     30 
     31 The first line contains two integer numbers *n* and *m* (1 ≤ *n*, *m* ≤ 100) — the sizes of the field.
     32 
     33 Each of the following *n* lines consisting of *m* characters 'R', 'G' and 'B' — the description of the field.
     34 
     35 Output
     36 
     37 Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 6 5  
     45 RRRRR  
     46 RRRRR  
     47 BBBBB  
     48 BBBBB  
     49 GGGGG  
     50 GGGGG
     51 ```
     52 
     53 Output
     54 
     55 ```
     56 YES
     57 ```
     58 
     59 Input
     60 
     61 ```
     62 4 3  
     63 BRG  
     64 BRG  
     65 BRG  
     66 BRG
     67 ```
     68 
     69 Output
     70 
     71 ```
     72 YES
     73 ```
     74 
     75 Input
     76 
     77 ```
     78 6 7  
     79 RRRGGGG  
     80 RRRGGGG  
     81 RRRGGGG  
     82 RRRBBBB  
     83 RRRBBBB  
     84 RRRBBBB
     85 ```
     86 
     87 Output
     88 
     89 ```
     90 NO
     91 ```
     92 
     93 Input
     94 
     95 ```
     96 4 4  
     97 RRRR  
     98 RRRR  
     99 BBBB  
    100 GGGG
    101 ```
    102 
    103 Output
    104 
    105 ```
    106 NO
    107 ```
    108 
    109 Note
    110 
    111 The field in the third example doesn't have three parralel stripes.
    112 
    113 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.