結果
| 問題 |
No.1506 Unbalanced Pocky Game
|
| コンテスト | |
| ユーザー |
c-yan
|
| 提出日時 | 2021-05-14 23:04:42 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 260 ms / 2,000 ms |
| コード長 | 612 bytes |
| コンパイル時間 | 469 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 51,488 KB |
| 最終ジャッジ日時 | 2024-10-02 03:46:20 |
| 合計ジャッジ時間 | 9,178 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 63 |
ソースコード
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 == 0:
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')
c-yan