Question: rust Problem 3 . Omok ( a . k . a . , Gomoku ) Omok is a game played on a Go board with

rust
Problem 3. Omok (a.k.a., Gomoku)
Omok is a game played on a Go board with black and white stones placed alternately. The board has 19 horizontal lines and 19 vertical lines, with the horizontal lines numbered from 1 to 19 from top to bottom, and the vertical lines numbered from 1 to 19 from left to right. In the above figure, if five consecutive stones of the same color are placed, that color wins. "consecutive" means in the horizontal, vertical, or diagonal direction. Thus, the figure shows a case where the black stones have won. However, if six or more stones are placed consecutively, it does not count as a win. Given a state of the Go board as input, write a program to determine whether the black stones have won, the white stones have won, or if the game is still undecided. Note that the input will not include cases where both black and white win simultaneously, or where either color wins in two or more places at the same time.
Input
Each of the 19 lines is represented by 19 numbers, where a black stone is denoted by 1, a white stone by 2, and an empty space is represented by 0. The numbers are displayed with a space between each.
Output
In the first line, print 1 if black wins, 2 if white wins, or 0 if the game is undecided. If black or white wins, print the row and column number of the leftmost stone among the five consecutive stones (if the five consecutive stones are placed vertically, print the topmost stone) in the second line.
Example
Input
0000000000000000000
0000000000000000000
0120022210000000000
0012000010000000000
0001200000000000000
0000122000000000000
0011010000000000000
0000002100000000000
0000000000000000000
0000000000000000000
0000000000000000000
0000000000000000000
0000000000000000000
0000000000000000000
0000000000000000000
0000000000000000000
0000000000000000000
0000000000000000000
0000000000000000000
Output
1
32

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!