#P3192. [HNOI2007] 胜负一子
[HNOI2007] 胜负一子
Description
Gomoku is a widely played board game. On a board, two players play with black and white stones (similar to Go). Black moves first. Once a stone is placed, it cannot be lifted; that is, there are no moving or capturing moves.
To simplify the problem, assume there are no “forbidden moves” for Black. “Forbidden moves” is a Gomoku term referring to places where a move is not allowed. When a player first forms a connected line of stones in one of the horizontal, vertical, -degree diagonal, or -degree diagonal directions, that player wins.
Consider an endgame position with Black to move. Please output the minimum number of moves for Black to win and all distinct next moves that allow Black to win in that number of moves.
Input Format
There are lines, each containing integers separated by a space. Let the integer in the -th row and the -th column be . Use to indicate that the position at row , column is empty, has a black stone, or has a white stone, respectively. Input is given from the top-left corner, in left-to-right and top-to-bottom order. That is, the first integer represents the state of row , column , and the last integer represents the state of row , column .
Output Format
The first line contains two integers and , where is the minimum number of moves for Black to win, and is the number of distinct next moves by which Black can win in moves.
From the second line to the -th line, each line contains two integers that represent a row and a column for one such next move by Black that leads to a win in moves. These moves must be sorted in ascending order by .
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 2 0 0 0 0 0
0 0 0 0 0 0 0 2 0 2 0 0 0 0 0
0 0 0 0 0 0 2 1 1 2 0 0 0 0 0
0 0 0 0 0 0 0 1 2 1 0 0 0 0 0
0 0 0 0 0 0 2 1 1 1 1 2 0 0 0
0 0 0 0 0 0 0 1 0 1 0 1 0 0 0
0 0 0 0 0 0 2 2 0 1 1 0 2 0 0
0 0 0 0 0 0 0 0 0 2 0 2 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3 2
10 9
10 11
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号