結果
| 問題 |
No.859 路線A、路線B、路線C
|
| コンテスト | |
| ユーザー |
brthyyjp
|
| 提出日時 | 2021-03-05 06:38:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 1,000 ms |
| コード長 | 666 bytes |
| コンパイル時間 | 170 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 52,224 KB |
| 最終ジャッジ日時 | 2024-10-05 23:42:39 |
| 合計ジャッジ時間 | 1,416 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
x, y, z = map(int, input().split())
s0, t0 = map(str, input().split())
s1, t1 = map(str, input().split())
t0 = int(t0)-1
t1 = int(t1)-1
L = [x, y, z]
s0 = ord(s0)-ord('A')
s1 = ord(s1)-ord('A')
INF = 10**18
ans = INF
if s0 == s1:
if t0 > t1:
t0, t1 = t1, t0
ans = min(ans, abs(t0-t1))
for i in range(3):
if i == s0:
continue
ans = min(ans, t0+1+L[i]-1+L[s0]-t1)
else:
ans = min(ans, t0+t1+1)
ans = min(ans, L[s0]-1-t0+L[s1]-1-t1+1)
for i in range(3):
if i == s0 or i == s1:
continue
ans = min(ans, t0+1+L[i]-1+L[s1]-t1)
ans = min(ans, t1+1+L[i]-1+L[s0]-t0)
print(ans)
brthyyjp