結果
| 問題 |
No.859 路線A、路線B、路線C
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 21:44:37 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 615 bytes |
| コンパイル時間 | 359 ms |
| コンパイル使用メモリ | 82,004 KB |
| 実行使用メモリ | 53,696 KB |
| 最終ジャッジ日時 | 2025-06-12 21:49:06 |
| 合計ジャッジ時間 | 1,631 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 WA * 5 |
ソースコード
x, y, z = map(int, input().split())
S0, t0 = input().split()
t0 = int(t0)
S1, t1 = input().split()
t1 = int(t1)
if S0 == S1:
print(abs(t0 - t1))
else:
routes = {'A': (1, x), 'B': (1, y), 'C': (1, z)}
S = S0
T = S1
S_start, S_end = routes[S]
T_start, T_end = routes[T]
# Compute the four possible costs
cost1 = abs(t0 - S_start) + 1 + abs(t1 - T_start)
cost2 = abs(t0 - S_end) + 1 + abs(t1 - T_end)
cost3 = abs(t0 - S_start) + 2 + abs(t1 - T_end)
cost4 = abs(t0 - S_end) + 2 + abs(t1 - T_start)
min_cost = min(cost1, cost2, cost3, cost4)
print(min_cost)
gew1fw