結果
| 問題 | No.3845 eval("G4M3") |
| コンテスト | |
| ユーザー |
tko919
|
| 提出日時 | 2026-12-03 00:30:42 |
| 結果 |
AC
不安定
|
| 実行時間 | 862 ms / 2,000 ms |
| + 878µs | |
| コード長 | 1,209 bytes |
| 記録 | |
| コンパイル時間 | 89 ms |
| コンパイル使用メモリ | 64,380 KB |
| 実行使用メモリ | 100,216 KB |
| 最終ジャッジ日時 | 2026-12-03 00:31:08 |
| 合計ジャッジ時間 | 11,994 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 49 |
ソースコード
from functools import lru_cache
def naive(s):
n=len(s)
# 1:Alice,0:Bob
@lru_cache(None)
def rec(t,turn):
# print(t,turn)
if len(t)==n*2-1:
return eval(t)&1
for i in range(len(t)-1):
if (t[i].isdigit()) and (t[i+1].isdigit()):
nt=t[:i+1]+'+'+t[i+1:]
if rec(nt,turn^1)==turn:
return turn
nt=t[:i+1]+'*'+t[i+1:]
if rec(nt,turn^1)==turn:
return turn
return turn^1
return rec(s,1)
def solve(s):
n=len(s)
if n%2==0:
return s[0]=='1' or s[-1]=='1' or ("11" in s)
else:
return s[0]!=s[-1] and ("11" not in s)
# for n in range(1,10):
# ret=0
# for mask in range(1<<n):
# s=""
# for i in range(n):
# s+=('1' if mask>>i&1 else '0')
# if naive(s)!=solve(s):
# print(s)
# ret+=1
# print(n,ret)
T=int(input())
for _ in range(T):
n=int(input())
s=str(input())
t=""
for c in s:
if ord(c)%2==0:
t+='0'
else:
t+='1'
print("Alice" if solve(t) else "Bob")
tko919