結果
問題 |
No.859 路線A、路線B、路線C
|
ユーザー |
![]() |
提出日時 | 2025-03-20 20:56:21 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,478 bytes |
コンパイル時間 | 152 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 53,752 KB |
最終ジャッジ日時 | 2025-03-20 20:56:28 |
合計ジャッジ時間 | 1,308 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 6 |
ソースコード
x, y, z = map(int, input().split()) s_line, s_num = input().split() s_num = int(s_num) e_line, e_num = input().split() e_num = int(e_num) if s_line == e_line: print(abs(s_num - e_num)) else: # All possible cases for different line transitions # A to B if s_line == 'A' and e_line == 'B': cost = abs(s_num - 1) + 1 + abs(e_num - 1) # A to C elif s_line == 'A' and e_line == 'C': cost1 = abs(s_num - 1) + 1 + (y - 1) + 1 + abs(z - e_num) cost2 = abs(x - s_num) + 1 + abs(e_num - 1) cost = min(cost1, cost2) # B to A elif s_line == 'B' and e_line == 'A': cost1 = abs(s_num - 1) + 1 + abs(e_num - 1) cost2 = abs(y - s_num) + 1 + abs(z - 1) + 1 + abs(x - e_num) cost = min(cost1, cost2) # B to C elif s_line == 'B' and e_line == 'C': cost = abs(y - s_num) + 1 + abs(z - e_num) # C to A elif s_line == 'C' and e_line == 'A': cost1 = abs(s_num - 1) + 1 + abs(x - e_num) cost2 = abs(z - s_num) + 1 + (y - 1) + 1 + abs(e_num - 1) cost = min(cost1, cost2) # C to B elif s_line == 'C' and e_line == 'B': cost = abs(z - s_num) + 1 + abs(y - e_num) # B to C elif s_line == 'B' and e_line == 'C': cost = abs(y - s_num) + 1 + abs(z - e_num) # C to B (duplicate case) else: # All other cases should be handled by above conditions cost = 0 # This should theoretically never be reached print(cost)