結果

問題 No.1506 Unbalanced Pocky Game
ユーザー tobusakanatobusakana
提出日時 2022-11-20 09:36:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 766 ms / 2,000 ms
コード長 1,164 bytes
コンパイル時間 533 ms
コンパイル使用メモリ 81,856 KB
実行使用メモリ 375,112 KB
最終ジャッジ日時 2023-10-21 09:53:13
合計ジャッジ時間 18,364 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,556 KB
testcase_01 AC 39 ms
53,556 KB
testcase_02 AC 38 ms
53,556 KB
testcase_03 AC 58 ms
72,532 KB
testcase_04 AC 255 ms
191,780 KB
testcase_05 AC 309 ms
226,100 KB
testcase_06 AC 208 ms
166,716 KB
testcase_07 AC 146 ms
133,084 KB
testcase_08 AC 212 ms
168,500 KB
testcase_09 AC 317 ms
229,144 KB
testcase_10 AC 318 ms
232,656 KB
testcase_11 AC 150 ms
136,216 KB
testcase_12 AC 142 ms
130,284 KB
testcase_13 AC 84 ms
95,172 KB
testcase_14 AC 149 ms
135,604 KB
testcase_15 AC 136 ms
127,420 KB
testcase_16 AC 316 ms
228,108 KB
testcase_17 AC 157 ms
140,100 KB
testcase_18 AC 128 ms
121,124 KB
testcase_19 AC 119 ms
114,968 KB
testcase_20 AC 321 ms
232,132 KB
testcase_21 AC 142 ms
130,388 KB
testcase_22 AC 221 ms
174,528 KB
testcase_23 AC 42 ms
53,556 KB
testcase_24 AC 40 ms
53,556 KB
testcase_25 AC 430 ms
287,956 KB
testcase_26 AC 636 ms
366,204 KB
testcase_27 AC 766 ms
374,864 KB
testcase_28 AC 588 ms
359,892 KB
testcase_29 AC 597 ms
366,228 KB
testcase_30 AC 633 ms
375,056 KB
testcase_31 AC 628 ms
375,112 KB
testcase_32 AC 632 ms
372,652 KB
testcase_33 AC 626 ms
372,332 KB
testcase_34 AC 601 ms
359,364 KB
testcase_35 AC 594 ms
359,524 KB
testcase_36 AC 39 ms
53,700 KB
testcase_37 AC 41 ms
53,948 KB
testcase_38 AC 40 ms
53,724 KB
testcase_39 AC 40 ms
53,688 KB
testcase_40 AC 40 ms
53,604 KB
testcase_41 AC 40 ms
53,792 KB
testcase_42 AC 39 ms
53,804 KB
testcase_43 AC 40 ms
53,844 KB
testcase_44 AC 40 ms
53,660 KB
testcase_45 AC 39 ms
53,568 KB
testcase_46 AC 247 ms
179,004 KB
testcase_47 AC 124 ms
111,952 KB
testcase_48 AC 138 ms
120,276 KB
testcase_49 AC 270 ms
191,976 KB
testcase_50 AC 252 ms
180,084 KB
testcase_51 AC 269 ms
187,592 KB
testcase_52 AC 214 ms
159,028 KB
testcase_53 AC 303 ms
204,548 KB
testcase_54 AC 152 ms
126,208 KB
testcase_55 AC 129 ms
113,648 KB
testcase_56 AC 125 ms
112,320 KB
testcase_57 AC 248 ms
179,324 KB
testcase_58 AC 119 ms
108,996 KB
testcase_59 AC 76 ms
85,320 KB
testcase_60 AC 166 ms
133,444 KB
testcase_61 AC 247 ms
176,740 KB
testcase_62 AC 185 ms
147,032 KB
testcase_63 AC 153 ms
128,752 KB
testcase_64 AC 267 ms
187,812 KB
testcase_65 AC 167 ms
134,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline

sys.setrecursionlimit((10 ** 5) * 3) 
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')

N = int(readline())
A = list(map(int,readline().split()))[::-1]

# Aiを渡されたときに取れる選択肢:
# ・次の数Ai+1を渡す
# ・今の数Aiを1にして渡す(Ai > 1)
# N+1個目を渡されたとき負けなので、N番目を渡されたときは勝ち

# 状態[i][p] = i番目の要素を、p:1=2以上で渡された、p:0=1で渡された
mem = [[False] * 2 for i in range(N)]
win = [[False] * 2 for i in range(N)]
mem[-1][0] = True
mem[-1][1] = True
win[-1][0] = True
win[-1][1] = True
# 最後の要素を渡されたら勝ちなので

def f(ind, p):
    if mem[ind][p]:
        return win[ind][p]
    res = False
    if p: # 1以上で渡された場合、1にして渡すことが出来る
        res |= not f(ind, 0)
    # 次の数を渡すことが出来る
    res |= not f(ind + 1, 1 if A[ind + 1] > 1 else 0) # 次の数が1より大きいか
    mem[ind][p] = True
    win[ind][p] = res
    return res
    
if f(0, 1 if A[0] > 1 else 0):
    print("Alice")
else:
    print("Bob")
0