結果

問題 No.859 路線A、路線B、路線C
ユーザー tkr182tkr182
提出日時 2019-09-19 23:58:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 1,000 ms
コード長 530 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 10,652 KB
実行使用メモリ 7,836 KB
最終ジャッジ日時 2023-09-28 22:04:03
合計ジャッジ時間 1,243 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,716 KB
testcase_01 AC 16 ms
7,804 KB
testcase_02 AC 16 ms
7,624 KB
testcase_03 AC 16 ms
7,676 KB
testcase_04 AC 16 ms
7,672 KB
testcase_05 AC 16 ms
7,672 KB
testcase_06 AC 16 ms
7,680 KB
testcase_07 AC 17 ms
7,656 KB
testcase_08 AC 16 ms
7,736 KB
testcase_09 AC 16 ms
7,652 KB
testcase_10 AC 17 ms
7,704 KB
testcase_11 AC 16 ms
7,748 KB
testcase_12 AC 17 ms
7,692 KB
testcase_13 AC 16 ms
7,696 KB
testcase_14 AC 16 ms
7,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

x,y,z=map(int,input().split())
s,t=map(str,input().split())
h,w=map(str,input().split())
t=int(t)
w=int(w)
if h<s:
    s,t,h,w=h,w,s,t
if s=="A":
    if h=="A":
        print(min(abs(t-w),x-abs(t-w)+min(y,z)))
    elif h=="B":
        print(min(t+w-1,x-t+y-w+1,t+y-w+z,x-t+w+z))
    else:
        print(min(t+w-1,x-t+z-w+1,t+z-w+y,x-t+w+y))
elif s=="B":
    if h=="B":
        print(min(abs(t-w),y-abs(t-w)+min(x,z)))
    else:
        print(min(t+w-1,y-t+z-w+1,t+z-w+x,y-t+w+x))
else:
    print(min(abs(t-w),z-abs(t-w)+min(x,y)))
0