結果

問題 No.859 路線A、路線B、路線C
ユーザー suika_psuika_p
提出日時 2019-08-09 22:38:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,498 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 8,248 KB
最終ジャッジ日時 2023-09-26 20:52:50
合計ジャッジ時間 1,137 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,192 KB
testcase_01 AC 16 ms
8,200 KB
testcase_02 AC 16 ms
8,000 KB
testcase_03 AC 16 ms
8,092 KB
testcase_04 AC 16 ms
8,248 KB
testcase_05 AC 15 ms
8,140 KB
testcase_06 AC 15 ms
8,112 KB
testcase_07 AC 16 ms
8,040 KB
testcase_08 AC 15 ms
8,092 KB
testcase_09 WA -
testcase_10 AC 15 ms
8,100 KB
testcase_11 AC 15 ms
8,100 KB
testcase_12 WA -
testcase_13 AC 15 ms
8,096 KB
testcase_14 AC 15 ms
8,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

x, y, z = map(int, input().split())
tmp1 = list(input().split())
tmp2 = list(input().split())
ss = tmp1[0]
s = int(tmp1[1])
sg = tmp2[0]
g = int(tmp2[1])

if ss == 'A':
    if sg == 'B':
        d1 = s + g - 1
        d2 = (x - s) + (y - g) + 1
        print(min(d1, d2))
    elif sg == 'C':
        d1 = s - 1 + g
        d2 = s - 1 + y + (z - g) + 1
        d3 = (x - s) + (z - g) + 1
        d4 = (x - s) + y + g
        print(min(d1, d2, d3, d4))
    else:
        if g < s:
            g, s = s, g
        d1 = abs(g - s)
        d2 = (s - 1) + y + (x - g) + 1
        print(min(d1, d2))
elif ss == 'B':
    if sg == 'A':
        s, g = g, s
        d1 = s + g - 1
        d2 = (x - s) + (y - g) + 1
        print(min(d1, d2))
    elif sg == 'C':
        d1 = s - 1 + g
        d2 = (y - s) + (z - g) + 1
        print(min(d1, d2))
    else:
        if g < s:
            g, s = s, g
        d1 = abs(g - s)
        d2 = (s - 1) + x + (y - g) + 1
        d3 = (s - 1) + z + (y - g) + 1
        print(min(d1, d2))
elif ss == 'C':
    if sg == 'A':
        s, g = g, s
        d1 = s - 1 + g
        d2 = s - 1 + y + (z - g) + 1
        d3 = (x - s) + (z - g) + 1
        d4 = (x - s) + y + g
        print(min(d1, d2, d3, d4))
    elif sg == 'B':
        s, g = g, s
        d1 = s - 1 + g
        d2 = (y - s) + (z - g) + 1
        print(min(d1, d2))
    else:
        if g < s:
            g, s = s, g
        d1 = abs(g - s)
        d2 = (s - 1) + y + (x - g) + 1
        print(min(d1, d2))
0