![]() |
||||||||||
|
||||||||||
Problem GTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1 Accepted Submission(s): 1 Problem Description Gomoku is an abstract strategy board game. Named Gobang or Five in a Row as well, it is traditionally played with pieces of two colors (black and white) on a board (with $N \times M$ intersections). Once a piece is placed, it is not allowed to be moved or removed from the chessboard. The rules of the game are quite simple. The black plays first, and two players alternate in placing a stone of their own color on an empty intersection. The winner is the first one who gets an unbroken row of five stones of his/her color horizontally, vertically, or diagonally. Now we have already drawn some stages of the game, and you're required to answer, that for each stage whether it is possible to reach, and if so, who has already won the game. You have to solve it as soon as possible, because there are no much time left in the competition now! Input The number of test cases $T (T \leq 150)$ will occur in the first line of input. For each test case: The first line contains the size of the board $N$ and $M (1 \leq N, M \leq 100)$. Then $N$ lines followed, each with exactly $M$ characters. The white stone is denoted by '1', and the black stone is denoted by '2', while the empty intersections are denoted by '.' (a full period). Output For each test case, if it is impossible to arrive at such a stage, output “fault”. Otherwise, if the white piece wins, then output “white”; if the black piece wins, output “black”; or else output “other”. Sample Input
Sample Output
Source | ||||||||||
|