結果
| 問題 |
No.2813 Cookie
|
| コンテスト | |
| ユーザー |
vwxyz
|
| 提出日時 | 2024-09-07 00:46:50 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 189 ms / 2,000 ms |
| コード長 | 869 bytes |
| コンパイル時間 | 445 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-09-07 00:46:57 |
| 合計ジャッジ時間 | 6,327 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
from functools import lru_cache
@lru_cache(maxsize=None)
def check(N):
st=set()
st.add(0)
if N>=2:
for bit in range(1,1<<N-1):
bound=[0]
for i in range(N-1):
if bit&1<<i:
bound.append(i+1)
bound.append(N)
g=0
for l,r in zip(bound,bound[1:]):
g^=check(r-l)
st.add(g)
g=0
while g in st:
g+=1
return g
def grundy(N):
if N<=2:
retu=1
elif N<=4:
retu=2
else:
N-=5
if N%3<2:
retu=N//3*4+4
else:
retu=N//3*4+6
return retu
T=int(input())
for t in range(T):
N=int(input())
A=list(map(int,input().split()))
g=0
for a in A:
g^=grundy(a)
if g:
ans="Alice"
else:
ans="Bob"
print(ans)
vwxyz