結果
問題 |
No.1506 Unbalanced Pocky Game
|
ユーザー |
![]() |
提出日時 | 2021-05-14 23:02:49 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 613 bytes |
コンパイル時間 | 99 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 51,368 KB |
最終ジャッジ日時 | 2024-10-02 03:43:00 |
合計ジャッジ時間 | 8,554 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 51 WA * 12 |
ソースコード
from sys import setrecursionlimit setrecursionlimit(10 ** 6) N, *A = map(int, open(0).read().split()) cache = [[None] * (N + 1) for _ in range(2)] def f(i, turn): if i == -1: return turn ^ 1 if cache[turn][i] is not None: return cache[turn][i] if A[i - 1] == 1: t = f(i - 1, turn ^ 1) cache[turn][i] = t return t t = f(i - 1, turn) if t == turn: cache[turn][i] = t return t t = f(i - 1, turn ^ 1) cache[turn][i] = t return t # turn = 0 Alice # turn = 1 Bob if f(N, 0) == 0: print('Alice') else: print('Bob')