|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||512 MB||6||3||3||50.000%|
Alice and Bob are playing a generalized version of Connect Four. In their game, the board consists of $w$ columns of height $h$ and the goal is to be the first player to complete a row of $k$ tiles of equal colour, either vertically, horizontally or diagonally. The two players alternate dropping their tiles into one of the columns, with Alice using red tiles and going first and Bob using yellow tiles and going second. Once a tile is dropped, it falls down to the bottommost available position, making that position no longer available. Once a column has $h$ tiles in it, it becomes full and the players can no longer drop their tiles there.
Figure G.1: Visualisation of the sample cases, showing the state of the game after 0, 3, 8 and 12 moves, respectively. Alice's tiles are shown in red, Bob's tiles in yellow.
As Alice and Bob found it quite challenging to keep track of the winning condition, they just kept playing until the board was completely filled with tiles. They recorded a log of the moves they made and asked you to tell them who won the game, and on what turn they did so. If neither player managed to complete a row, the game ends in a draw, so report that instead.
The input consists of:
Output the winner of the game (
A for Alice or
B for Bob), followed by the number of moves needed to decide the winner. If the game ends in a draw, output
4 3 2 1 1 2 3 3 2 2 1 1 2 3 3
4 3 3 1 1 2 3 3 2 2 1 1 2 3 3
4 3 4 1 1 2 3 3 2 2 1 1 2 3 3