結果

問題 No.2278 Time Bomb Game 2
ユーザー sotanishysotanishy
提出日時 2023-04-21 22:32:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 1,195 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 71,976 KB
最終ジャッジ日時 2024-04-24 09:38:20
合計ジャッジ時間 5,698 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,096 KB
testcase_01 AC 38 ms
52,096 KB
testcase_02 AC 40 ms
52,480 KB
testcase_03 AC 40 ms
52,480 KB
testcase_04 AC 39 ms
52,480 KB
testcase_05 AC 39 ms
52,224 KB
testcase_06 AC 49 ms
61,440 KB
testcase_07 AC 52 ms
67,456 KB
testcase_08 AC 42 ms
57,472 KB
testcase_09 AC 44 ms
62,260 KB
testcase_10 AC 51 ms
68,864 KB
testcase_11 AC 57 ms
71,424 KB
testcase_12 AC 58 ms
71,168 KB
testcase_13 AC 50 ms
68,864 KB
testcase_14 AC 57 ms
71,936 KB
testcase_15 AC 52 ms
68,864 KB
testcase_16 AC 51 ms
69,376 KB
testcase_17 AC 57 ms
71,976 KB
testcase_18 AC 54 ms
68,992 KB
testcase_19 AC 57 ms
71,452 KB
testcase_20 AC 54 ms
70,144 KB
testcase_21 AC 46 ms
62,848 KB
testcase_22 AC 53 ms
69,888 KB
testcase_23 AC 45 ms
62,976 KB
testcase_24 AC 46 ms
63,360 KB
testcase_25 AC 55 ms
70,272 KB
testcase_26 AC 53 ms
70,144 KB
testcase_27 AC 54 ms
70,272 KB
testcase_28 AC 53 ms
70,144 KB
testcase_29 AC 54 ms
70,144 KB
testcase_30 AC 55 ms
70,272 KB
testcase_31 AC 46 ms
62,876 KB
testcase_32 AC 46 ms
62,944 KB
testcase_33 AC 48 ms
62,976 KB
testcase_34 AC 54 ms
70,016 KB
testcase_35 AC 55 ms
70,272 KB
testcase_36 AC 45 ms
63,104 KB
testcase_37 AC 55 ms
70,912 KB
testcase_38 AC 55 ms
71,040 KB
testcase_39 AC 50 ms
68,644 KB
testcase_40 AC 56 ms
71,680 KB
testcase_41 AC 50 ms
68,864 KB
testcase_42 AC 54 ms
70,864 KB
testcase_43 AC 56 ms
71,168 KB
testcase_44 AC 50 ms
68,864 KB
testcase_45 AC 55 ms
71,168 KB
testcase_46 AC 55 ms
71,424 KB
testcase_47 AC 50 ms
68,352 KB
testcase_48 AC 50 ms
68,864 KB
testcase_49 AC 56 ms
71,680 KB
testcase_50 AC 53 ms
70,144 KB
testcase_51 AC 55 ms
70,528 KB
testcase_52 AC 45 ms
62,720 KB
testcase_53 AC 45 ms
63,196 KB
testcase_54 AC 46 ms
62,976 KB
testcase_55 AC 45 ms
62,592 KB
testcase_56 AC 52 ms
69,888 KB
testcase_57 AC 45 ms
63,256 KB
testcase_58 AC 51 ms
70,144 KB
testcase_59 AC 46 ms
63,104 KB
testcase_60 AC 55 ms
70,528 KB
testcase_61 AC 53 ms
70,400 KB
testcase_62 AC 47 ms
62,592 KB
testcase_63 AC 53 ms
70,016 KB
testcase_64 AC 60 ms
71,680 KB
testcase_65 AC 56 ms
71,040 KB
testcase_66 AC 56 ms
71,680 KB
testcase_67 AC 52 ms
69,504 KB
testcase_68 AC 55 ms
71,168 KB
testcase_69 AC 49 ms
68,736 KB
testcase_70 AC 50 ms
68,480 KB
testcase_71 AC 38 ms
51,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N, K, T = map(int, input().split())
c = list(input().rstrip())
K -= 1

flip = False
if c[K] == 'B':
    flip = True
    c = ['B' if x == 'A' else 'A' for x in c]


def answer(ans):
    if ans == 0:
        print("Alice" if not flip else "Bob")
    else:
        print("Bob" if not flip else "Alice")


dist = []
for i in range(K+1, N):
    if i-K > T:
        break
    if c[i] == 'B':
        dist.append(i - K)
        break
for i in range(K)[::-1]:
    if K-i > T:
        break
    if c[i] == 'B':
        dist.append(K - i)
        break

if not dist:
    answer(1)
    exit()

if max(dist) > 1:
    if any(T % 2 == d % 2 for d in dist):
        answer(0)
    else:
        answer(1)
else:
    if T % 2 == 0:
        answer(1)
    else:
        if T == 1:
            answer(0)
        else:
            # check right
            i = K+1
            while i < N and c[i] == 'B':
                i += 1
            right = i-(K+1) <= T-1 and (i-(K+1)) % 2 == 0

            i = K-1
            while i >= 0 and c[i] == 'B':
                i -= 1
            left = (K-1)-i <= T-1 and ((K-1)-i) % 2 == 0

            answer(1 if left and right else 0)
0