#P8658. [蓝桥杯 2017 国 A] 填字母游戏
[蓝桥杯 2017 国 A] 填字母游戏
Description
Xiaoming often plays the game LOL and is addicted to it. One time he wanted to challenge Master K, but Master K said:
“Let’s first play a game of filling letters into blanks. If you can’t beat me, then don’t play LOL anymore.”
Master K draws a row of cells on paper, and asks Xiaoming and him to take turns filling letters into them.
Rules:
-
When it is someone’s turn, they can only fill
LorOinto one empty cell. -
Whoever first makes the letters form the string
LOLwins. -
If all cells are filled and
LOLstill cannot be formed, then it is a draw.
Xiaoming tried several times and lost every time. He feels ashamed and hopes you can help him solve this puzzle using a computer.
Input Format
The input format is:
The first line contains an integer (), meaning there are initial positions below.
Next, there are lines. Each line contains a string (length ), representing the starting position.
For example: ****** means there are empty cells.
L**** means the leftmost cell is the letter L, and to its right there are empty cells.
Output Format
Output numbers. For each position, if Xiaoming plays first and Master K always uses the strongest moves, output Xiaoming’s best possible result.
1 means Xiaoming can win.
-1 means Xiaoming will definitely lose.
0 means Xiaoming can force a draw.
4
***
L**L
L**L***L
L*****L
0
-1
1
1
Hint
Time limit: 1 second, 256M. Lanqiao Cup, 2017, the 8th National Finals.
Translated by ChatGPT 5
京公网安备 11011102002149号