結果

問題 No.859 路線A、路線B、路線C
コンテスト
ユーザー akitsugu777
提出日時 2019-09-02 13:13:12
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 91 ms / 1,000 ms
コード長 765 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 342 ms
コンパイル使用メモリ 20,824 KB
実行使用メモリ 15,232 KB
最終ジャッジ日時 2026-05-25 17:31:07
合計ジャッジ時間 2,738 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

a, b, c = map(int,input().split())
S = input().split()
s = int(S[1])
G = input().split()
g = int(G[1])

l = []
if S[0] == G[0]:
    if s > g:
        s, g = g, s
    if S[0] == 'B':
        a, b, c = b, a, c
    elif S[0] == 'C':
        a, b, c = c, b, a
    l.append(g-s)
    l.append(s+c+(a-g))
    l.append(s+b+(a-g))

else:
    if S[0] == 'A' and G[0] == 'B':
        a, b, c = a, c, b
    elif S[0] == 'B' and G[0] == 'A':
        a, b, c = b, c, a
    elif S[0] == 'B' and G[0] == 'C':
        a, b, c = b, a, c
    elif S[0] == 'C' and G[0] == 'A':
        a, b, c = c, b, a
    elif S[0] == 'C' and G[0] == 'B':
        a, b, c = c, a, b
    l.append((s+g-1))
    l.append(((a-s)+(c-g)+1))
    l.append(((a-s)+b+g))
    l.append((s+b+(c-g)))

print(min(l))
0