結果
問題 |
No.859 路線A、路線B、路線C
|
ユーザー |
![]() |
提出日時 | 2025-04-09 20:59:57 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,087 bytes |
コンパイル時間 | 147 ms |
コンパイル使用メモリ | 82,536 KB |
実行使用メモリ | 54,280 KB |
最終ジャッジ日時 | 2025-04-09 21:00:46 |
合計ジャッジ時間 | 1,297 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 2 |
ソースコード
x, y, z = map(int, input().split()) s_line, s_num = input().split() e_line, e_num = input().split() s_num = int(s_num) e_num = int(e_num) if s_line == e_line: print(abs(s_num - e_num)) else: # Determine X (start line) and Y (end line) parameters if s_line == 'A': x_end = x a = s_num elif s_line == 'B': x_end = y a = s_num else: # 'C' x_end = z a = s_num if e_line == 'A': y_end = x b = e_num elif e_line == 'B': y_end = y b = e_num else: # 'C' y_end = z b = e_num # Calculate all options option1 = (a - 1) + (b - 1) + 1 # Via first hubs option2 = (x_end - a) + (y_end - b) + 1 # Via end hubs min_len = min(x, y, z) option3 = (a - 1) + (y_end - b) + min_len + 1 # Via X's first -> Z's first -> Z's end -> Y's end option4 = (x_end - a) + (b - 1) + min_len + 1 # Via X's end -> Z's end -> Z's first -> Y's first # Find the minimal cost min_cost = min(option1, option2, option3, option4) print(min_cost)