結果

問題 No.3342 AAB Game
コンテスト
ユーザー tassei903
提出日時 2025-11-14 00:19:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 842 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 82,400 KB
実行使用メモリ 65,128 KB
最終ジャッジ日時 2025-11-14 00:19:35
合計ジャッジ時間 3,893 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

"""
A しかないなら負け

B が一個以下 勝ち


"""

from functools import lru_cache
@lru_cache(maxsize=None)
def naive(s):
    n = len(s)
    res = 0
    for i in range(n):
        if s[i] == "B":
            for j in range(i + 1):
                if s[j:i] == "A" * (i - j):
                    res |= 1 ^ naive(s[:j] + "B" * (i - j) + "A" + s[i+1:])
    return res

def solve(s):
    t = 0
    for i in range(n):
        t += (s[i] == "B") * (1 if i % 2 else -1)
    return t % 3 != 0


# from itertools import product
# for n in range(1, 10):
#     cnt = 0
#     for s in product("AB", repeat=n):
#         s = "".join(s)[::-1]
#         cnt += 1 - naive(s)
#         # if naive(s) == 0:
#         #     print(s)
#     print(n, cnt)
n = int(input())
s = input()

res = solve(s)
if res:
    print("Alice")
else:
    print("Bob")
0