Color Weakness
InterviewTime limit1sMemory limit128 MB
Count connected R, G, B regions in an N by N grid twice, once normally and once with R and G merged.
Problem
People with red-green color weakness barely distinguish red from green. The regions they see in a picture can differ from what others see.
Each cell of an grid is painted R (red), G (green), or B (blue). A region is a set of cells connected through up, down, left, or right adjacency with the same color. For color-weak vision, R and G count as the same color.
Given the picture, output the number of regions for normal vision and for color-weak vision.
Input
- Line 1: integer ().
- Next lines: the picture.
Output
Print two integers separated by a space: region counts for normal vision and for color-weak vision.