結果

問題 No.2278 Time Bomb Game 2
ユーザー ntudantuda
提出日時 2023-04-24 19:46:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 1,696 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 60,032 KB
最終ジャッジ日時 2024-11-08 20:01:00
合計ジャッジ時間 6,527 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 70
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K,T = map(int,input().split())
C = input()
K -= 1
dic = {"A":"Alice","B":"Bob"}
now = C[K]
other = ["A","B"][now == "A"]
INF = 10 ** 10
R = L = INF

def cnt(start,dir,col):
    k = 0
    flag = 0
    ret = INF
    while 0 <= start + dir * (k + 1) < N:
        if C[start + dir * (k + 1)] != col:
            flag = 1
            ret = k
            break
        k += 1
    return ret

def out(x):
    print(dic[x])
    exit()

R = cnt(K,1,now)
L = cnt(K,-1,now)

if T <= L and T <= R:
    out(other)
if 0 < L < INF:
    if (L-T) % 2 == 1:
        out(now)
if 0 < R < INF:
    if (R-T) % 2 == 1:
        out(now)
# case, R == 0 or L == 0
if T % 2 == 1:
    if R == 0:
        R2 = cnt(K+1,1,other)
        if R2 % 2 == 0:
            out(now)
    if L == 0:
        L2 = cnt(K-1,-1,other)
        if L2 % 2 == 0:
            out(now)

out(other)
N,K,T = map(int,input().split())
C = input()
K -= 1
dic = {"A":"Alice","B":"Bob"}
now = C[K]
other = ["A","B"][now == "A"]
INF = 10 ** 10
R = L = INF

def cnt(start,dir,col):
    k = 0
    flag = 0
    ret = INF
    while 0 <= start + dir * (k + 1) < N:
        if C[start + dir * (k + 1)] != col:
            flag = 1
            ret = k
            break
        k += 1
    return ret

def out(x):
    print(dic[x])
    exit()

R = cnt(K,1,now)
L = cnt(K,-1,now)

if T <= L and T <= R:
    out(other)
if 0 < L < INF:
    if (L-T) % 2 == 1:
        out(now)
if 0 < R < INF:
    if (R-T) % 2 == 1:
        out(now)
# case, R == 0 or L == 0
if T % 2 == 1:
    if R == 0:
        R2 = cnt(K+1,1,other)
        if R2 % 2 == 0:
            out(now)
    if L == 0:
        L2 = cnt(K-1,-1,other)
        if L2 % 2 == 0:
            out(now)

out(other)
0