結果

問題 No.2103 ±1s Game
ユーザー gew1fw
提出日時 2025-06-12 12:52:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,090 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 82,908 KB
実行使用メモリ 54,000 KB
最終ジャッジ日時 2025-06-12 12:52:37
合計ジャッジ時間 2,662 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

X, Y, K, P = map(int, input().split())

T = X + Y - K

# Determine required_parity based on P
if P == 1:
    required_parity = 0  # Y_remaining must be even
    target_r_mod = Y % 2
else:  # P == -1
    required_parity = 1  # Y_remaining must be odd
    target_r_mod = (Y - 1) % 2

R_min = max(0, T - X)
R_max = min(Y, T)

# Check if there exists R in [R_min, R_max] with R mod 2 == target_r_mod
has_even = False
has_odd = False
for r in [R_min, R_max]:
    if r % 2 == 0:
        has_even = True
    else:
        has_odd = True
if R_min < R_max:
    has_even = has_odd = True  # because there's at least one even and one odd in between

exists = False
if (target_r_mod == 0 and has_even) or (target_r_mod == 1 and has_odd):
    exists = True

if not exists:
    print("Bob")
else:
    # Check if Alice can force the parity by choosing R_min or R_max
    if (target_r_mod == 0 and R_min % 2 == 0) or (target_r_mod == 1 and R_max % 2 == 1):
        print("Alice")
    else:
        # Check parity of T
        if T % 2 == 1:
            print("Alice")
        else:
            print("Bob")
0