結果
| 問題 |
No.859 路線A、路線B、路線C
|
| コンテスト | |
| ユーザー |
qwewe
|
| 提出日時 | 2025-05-14 12:54:14 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 631 bytes |
| コンパイル時間 | 387 ms |
| コンパイル使用メモリ | 81,792 KB |
| 実行使用メモリ | 52,096 KB |
| 最終ジャッジ日時 | 2025-05-14 12:55:30 |
| 合計ジャッジ時間 | 1,416 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 WA * 5 |
ソースコード
x, y, z = map(int, input().split())
s_line, s_num = input().split()
s_num = int(s_num)
t_line, t_num = input().split()
t_num = int(t_num)
if s_line == t_line:
print(abs(s_num - t_num))
else:
# Determine R_end and Q_end based on the lines
r_end = x if s_line == 'A' else y if s_line == 'B' else z
q_end = x if t_line == 'A' else y if t_line == 'B' else z
cost1 = (s_num - 1) + 1 + (t_num - 1)
cost2 = (r_end - s_num) + 1 + (q_end - t_num)
cost3 = (s_num - 1) + 1 + 1 + (q_end - t_num)
cost4 = (r_end - s_num) + 1 + 1 + (t_num - 1)
min_cost = min(cost1, cost2, cost3, cost4)
print(min_cost)
qwewe