RBGrid
You are given a mesh with n rows and m columns, where each field is colored in either Red or Blue. Write a program that will determine how many of the blue fields have all of its four adjacent fields to be blue as well. Two fields are adjacent if they share an edge (Up, Down, Left, Right)
InputFrom the first line of the standard input read two integers n i m (1 <= n, m <= 1 000).
From each of the next n lines read m characters. Each character will be either 'R' or 'B'. 'R' represents Red field and 'B' represents blue fields.
From each of the next n lines read m characters. Each character will be either 'R' or 'B'. 'R' represents Red field and 'B' represents blue fields.
OutputTo the standard output print out one integer representing the number of blue fields that have all of its four adjacent fields blue.
Input:
Output:
5 10
RBRRBBRBRB
RBRRBBBBRR
BBRBBBBBBB
RBRBBBBBRR
RRBBBRRBBBOutput:
6Input:
Output:
4 3
RBB
BBB
BBB
BBROutput:
2Explanation:
The two fields are the following ones. A field in the 2nd row, 2nd column, and a field in the 3rd row, 2nd column
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.