結果

問題 No.2278 Time Bomb Game 2
ユーザー miscalc
提出日時 2023-04-21 11:19:35
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 835 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 12,928 KB
最終ジャッジ日時 2024-11-06 07:41:14
合計ジャッジ時間 6,771 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 48 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(n, k, t, s):
  if s[k] == 'B':
    s2 = "".join(['A' if s[i] == 'B' else 'A' for i in range(n)])
    return not solve(n, k, t, s2)
  if (k != 0 and s[k-1] == 'A') or (k != n-1 and s[k+1] == 'A'):
    l, r = -1, -1
    for i in range(k-1, -1, -1):
      if s[i] == 'B':
        l = i
        break
    for i in range(k+1, n):
      if s[i] == 'B':
        r = i
        break
    if l != -1 and k - l <= t and (k - l) % 2 == t % 2:
      return True
    if r != -1 and r - k <= t and (r - k) % 2 == t % 2:
      return True
    return False
  else:
    if t % 2 == 0:
      return False
    if k != 0 and solve(n, k-1, t-1, s):
      return True
    if k != n-1 and solve(n, k+1, t-1, s):
      return True
    return False

n, k, t = map(int, input().split())
s = input()
k -= 1
print("Alice" if solve(n, k, t, s) else "Bob")
0