結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,908 KB
testcase_01 AC 16 ms
7,832 KB
testcase_02 AC 17 ms
7,792 KB
testcase_03 AC 17 ms
7,780 KB
testcase_04 AC 16 ms
7,880 KB
testcase_05 AC 16 ms
7,844 KB
testcase_06 AC 16 ms
7,808 KB
testcase_07 AC 17 ms
7,800 KB
testcase_08 AC 16 ms
7,700 KB
testcase_09 AC 16 ms
7,896 KB
testcase_10 WA -
testcase_11 AC 17 ms
7,812 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 16 ms
7,880 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+z))
elif s=="B":
    if h=="B":
        print(min(abs(t-w),x-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),x-abs(t-w)+min(x,y)))
0