ColoredStrokes
SRM 496 · 2010-11-01 · by gojira_tc
Problem Statement
You're given a
Constraints
- picture will contain between 1 and 50 elements, inclusive.
- Each element of picture will be between 1 and 50 characters long, inclusive.
- All elements of picture will have equal length.
- Each character in picture will be 'R', 'G', 'B' or '.'.
Statement by TopCoder, Inc. — view the original on the archive.
{"...",
"..."}
Returns: 0
The picture is blank, Manao made no strokes.
{"RRB"}
Returns: 2
{"..B.",
"..B."}
Returns: 1
A single vertical stroke is enough.
{"...B..",
".RRG.R",
"...B.."}
Returns: 3
{"G"}
Returns: 2
{".BB."}
Returns: 2
Since only vertical strokes are painted with blue color, this picture needs two strokes.
{"...B..",
".BRGRR",
".B.B.."}
Returns: 3
One horizontal and two vertical strokes are necessary for this masterpiece.
{"...B..",
".BRBRR",
".B.B.."}
Returns: 4
This is the same picture as in the previous case with pixel (3,1) colored blue instead of green. Therefore, a single horizontal stroke won't help.
Submissions are judged against all 141 archived test cases, of which 8 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class ColoredStrokes with a public method int getLeast(vector<string> picture) · 141 test cases · 2 s / 256 MB per case