結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,620 KB
testcase_01 AC 15 ms
7,800 KB
testcase_02 AC 15 ms
7,708 KB
testcase_03 AC 16 ms
7,804 KB
testcase_04 AC 15 ms
7,684 KB
testcase_05 AC 16 ms
7,800 KB
testcase_06 AC 16 ms
7,732 KB
testcase_07 AC 15 ms
7,840 KB
testcase_08 AC 16 ms
7,680 KB
testcase_09 AC 16 ms
7,804 KB
testcase_10 AC 16 ms
7,804 KB
testcase_11 AC 16 ms
7,704 KB
testcase_12 AC 16 ms
7,724 KB
testcase_13 AC 16 ms
7,672 KB
testcase_14 AC 16 ms
7,840 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