#P2346. 四子连棋

    ID: 1318 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>搜索广度优先搜索,BFS深度优先搜索,DFS哈希,HASH

四子连棋

Description

On a 4×44\times 4 board there are 1414 pieces: 77 white and 77 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 4×44\times 4 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