WhiteCells
SRM 367 · 2007-09-26 · by gevak
SRM 367 · 2007-09-26 · by gevak · Simple Search, Iteration
Problem Statement
Problem Statement
A chessboard is an 8 x 8 grid of cells. Within each column and within each row, cells alternate between black and white. The cell in the upper left corner (0, 0) is white. You are given a
Constraints
- board will contain exactly 8 elements.
- Each element of board will contain exactly 8 characters.
- board will contain only the characters '.' and 'F'.
Examples
0)
{"........",
"........",
"........",
"........",
"........",
"........",
"........",
"........"}
Returns: 0
1)
{"FFFFFFFF",
"FFFFFFFF",
"FFFFFFFF",
"FFFFFFFF",
"FFFFFFFF",
"FFFFFFFF",
"FFFFFFFF",
"FFFFFFFF"}
Returns: 32
2)
{".F.F...F",
"F...F.F.",
"...F.F.F",
"F.F...F.",
".F...F..",
"F...F.F.",
".F.F.F.F",
"..FF..F."}
Returns: 1
3)
{"........",
"..F.....",
".....F..",
".....F..",
"........",
"........",
".......F",
".F......"}
Returns: 2
4)
{"...F....", "F.......", "..F.....", "........",
"..F.....", ".....F..", ".F......", "......F."}
Returns: 3
Submissions are judged against all 48 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class WhiteCells with a public method int countOccupied(vector<string> board) · 48 test cases · 2 s / 256 MB per case