There is a strip 1 × n with two sides. Each square of the strip (their total amount is 2 n, n squares on each side) is painted in one of two colors (let’s call them A and B). Alice and Bob play a game. Alice makes the first turn. On each turn, a player can bend the strip in half with the fold passing on the divisions of the squares (i.e. the turn is possible only if the strip has an even length). Bending the strip can be done either inwards or outwards. If the strip has become completely one color after the next turn, then the winner is the player whose color is it ( A refers to Alice, B to Bob). If the current player has no legal moves, but no one has won, the game ends with a draw.
Who will win if both players play optimally? This means that each player tries to win; if it is not possible, to achieve a draw.
Input
The first line contains an integer n that is the length of the strip (1 ≤ n ≤ 5 · 10 5).
The next two lines contain two strings of letters “A
Game with a Strip URAL - 2104(神奇的dfs)
最新推荐文章于 2021-08-05 20:28:26 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)