結果

問題 No.1506 Unbalanced Pocky Game
ユーザー c-yan
提出日時 2021-05-14 22:58:18
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 527 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 24,436 KB
最終ジャッジ日時 2024-10-02 03:35:58
合計ジャッジ時間 5,966 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other WA * 2 RE * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache

from sys import setrecursionlimit

setrecursionlimit(10 ** 6)

N, *A = map(int, open(0).read().split())

for i in range(N):
    if A[i] == 1:
        continue
    A[i] = 2


@lru_cache(maxsize=None)
def f(i, turn):
    if i == -1:
        return turn ^ 1

    if A[i - 1] == 1:
        return f(i - 1, turn ^ 1)

    t = f(i, turn ^ 1)
    if t == turn:
        return t
    return f(i - 1, turn ^ 1)


# turn = 0 Alice
# turn = 1 Bob
if f(N, 0) == 0:
    print('Alice')
else:
    print('Bob')
0