← 返回 snowflake 的题目列表Connect Four Can Play Win
类型:online_judge
Given a Connect Four board and the current player, determine whether the player can win immediately by making exactly one move.
Simplified Connect Four rules:
The board size is fixed at 6 x 7.
Each cell is one of:
.: empty
R: red piece
Y: yellow piece
A player chooses a column, and the piece falls to the lowest empty cell in that column.
After the move, if the player has at least 4 consecutive pieces horizontally, vertically, or diagonally, the player wins.
Return whether there exists at least one valid column where the current player can drop a piece and win immediately.
Input Format
row1
row2
row3
row4
row5
row6
player
The first 6 lines describe the board from top to bottom. The last line is the current player, either R or Y.
Output Format
Print true or false.
Example
Input
.......
.......
.......
.......
.......
.......
R
Output
false