FoxAndGomoku
SRM 590 · 2013-06-25 · by cgy4ever
SRM 590 · 2013-06-25 · by cgy4ever · Brute Force
Problem Statement
Problem Statement
Fox Ciel is going to play Gomoku with her friend Fox Jiro.
Ciel plays better, so before they start she allowed Jiro to put some of his pieces on the board.
You are given aString[] board that represents a square board.
The character board[i][j] represents the cell with coordinates (i,j).
Each of those characters is either '.' (representing an empty cell) or 'o' (representing a cell with Jiro's piece).
Of course, Ciel does not want Jiro to win the game before she has a chance to play. Thus she now has to check the board and determine whether there are five consecutive tokens somewhere on the board.
Determine whether there are 5 consecutive cells (horizontally, vertically, or diagonally) that contain Jiro's tokens. Return "found" (quotes for clarity) if there are five such cells anywhere on the board. Otherwise, return "not found".
You are given a
Of course, Ciel does not want Jiro to win the game before she has a chance to play. Thus she now has to check the board and determine whether there are five consecutive tokens somewhere on the board.
Determine whether there are 5 consecutive cells (horizontally, vertically, or diagonally) that contain Jiro's tokens. Return "found" (quotes for clarity) if there are five such cells anywhere on the board. Otherwise, return "not found".
Constraints
- n will be between 5 and 15, inclusive.
- board will contain exactly n elements.
- Each element in board will contain exactly n characters.
- Each character in board will be 'o' or '.'.
Examples
0)
{"....o.",
"...o..",
"..o...",
".o....",
"o.....",
"......"}
Returns: "found"
There is five continue pieces diagonally.
1)
{"oooo.",
".oooo",
"oooo.",
".oooo",
"....."}
Returns: "not found"
There is no five-in-a-row on this board.
2)
{"oooo.",
".oooo",
"oooo.",
".oooo",
"....o"}
Returns: "found"
Five consecutive tokens can be found in the following cells: (0,0), (1,1), (2,2), (3,3), and (4,4).
3)
{"o.....",
".o....",
"..o...",
"...o..",
"....o.",
"......"}
Returns: "found"
4)
{"o....",
"o.o..",
"o.o.o",
"o.o..",
"o...."}
Returns: "found"
Submissions are judged against all 87 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class FoxAndGomoku with a public method string win(vector<string> board) · 87 test cases · 2 s / 256 MB per case