Game with a Strip URAL - 2104(神奇的dfs)

Alice和Bob玩一个折纸条游戏,纸条两面分别涂有A和B两种颜色。每次玩家可以将纸条对折,目标是使得折完后纸条一面全为自己的颜色。如果两个玩家都发挥最佳策略,谁会赢?输入纸条长度和颜色分布,输出赢家。
摘要由CSDN通过智能技术生成

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值