#P2346. 四子连棋
四子连棋
Description
On a board there are pieces: white and black, with two empty cells. Any piece may move up, down, left, or right into an adjacent empty cell; this counts as one move. Black and white move alternately, and either side may move first. If at any time the pieces of either color form four in a line (including diagonals), that state is a target board position.

Input Format
Read a initial board from the file. Black pieces are denoted by B, white pieces by W, and empty cells by O.
Output Format
Output the minimum number of moves required to reach a target board position.
BWBO
WBWB
BWBW
WBWO
5
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号