結果

問題 No.859 路線A、路線B、路線C
ユーザー kohei2019kohei2019
提出日時 2022-05-04 13:14:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 70 ms / 1,000 ms
コード長 500 bytes
コンパイル時間 714 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 71,548 KB
最終ジャッジ日時 2023-09-16 15:28:30
合計ジャッジ時間 2,631 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,276 KB
testcase_01 AC 70 ms
71,400 KB
testcase_02 AC 70 ms
71,548 KB
testcase_03 AC 70 ms
71,492 KB
testcase_04 AC 69 ms
71,004 KB
testcase_05 AC 70 ms
71,368 KB
testcase_06 AC 67 ms
71,032 KB
testcase_07 AC 70 ms
71,248 KB
testcase_08 AC 69 ms
71,080 KB
testcase_09 AC 70 ms
71,428 KB
testcase_10 AC 70 ms
71,260 KB
testcase_11 AC 69 ms
71,500 KB
testcase_12 AC 70 ms
71,380 KB
testcase_13 AC 70 ms
71,492 KB
testcase_14 AC 70 ms
71,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

ls = list(map(int,input().split()))
S0,t0 = input().split()
S1,t1 = input().split()
l = 'ABC'
s = [l.index(S0),int(t0)-1]
g = [l.index(S1),int(t1)-1]
if s[0] == g[0]:
    a = ls.pop(s[0])
    ans = min(abs(s[1]-g[1]),a-abs(s[1]-g[1])+ls[0],a-abs(s[1]-g[1])+ls[1])
else:
    ans = min(s[1]+g[1]+1,ls[s[0]]-s[1]-1+ls[g[0]]-g[1]-1+1)
    aa = set([0,1,2])
    aa.remove(s[0])
    aa.remove(g[0])
    n = list(aa)[0]
    ans = min(ans,s[1]+ls[g[0]]-g[1]-1+ls[n]+1,g[1]+ls[s[0]]-s[1]-1+ls[n]+1)
print(ans)
0