結果
問題 |
No.859 路線A、路線B、路線C
|
ユーザー |
![]() |
提出日時 | 2019-08-09 22:38:06 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,498 bytes |
コンパイル時間 | 88 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-07-19 14:42:09 |
合計ジャッジ時間 | 1,298 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 2 |
ソースコード
x, y, z = map(int, input().split()) tmp1 = list(input().split()) tmp2 = list(input().split()) ss = tmp1[0] s = int(tmp1[1]) sg = tmp2[0] g = int(tmp2[1]) if ss == 'A': if sg == 'B': d1 = s + g - 1 d2 = (x - s) + (y - g) + 1 print(min(d1, d2)) elif sg == 'C': d1 = s - 1 + g d2 = s - 1 + y + (z - g) + 1 d3 = (x - s) + (z - g) + 1 d4 = (x - s) + y + g print(min(d1, d2, d3, d4)) else: if g < s: g, s = s, g d1 = abs(g - s) d2 = (s - 1) + y + (x - g) + 1 print(min(d1, d2)) elif ss == 'B': if sg == 'A': s, g = g, s d1 = s + g - 1 d2 = (x - s) + (y - g) + 1 print(min(d1, d2)) elif sg == 'C': d1 = s - 1 + g d2 = (y - s) + (z - g) + 1 print(min(d1, d2)) else: if g < s: g, s = s, g d1 = abs(g - s) d2 = (s - 1) + x + (y - g) + 1 d3 = (s - 1) + z + (y - g) + 1 print(min(d1, d2)) elif ss == 'C': if sg == 'A': s, g = g, s d1 = s - 1 + g d2 = s - 1 + y + (z - g) + 1 d3 = (x - s) + (z - g) + 1 d4 = (x - s) + y + g print(min(d1, d2, d3, d4)) elif sg == 'B': s, g = g, s d1 = s - 1 + g d2 = (y - s) + (z - g) + 1 print(min(d1, d2)) else: if g < s: g, s = s, g d1 = abs(g - s) d2 = (s - 1) + y + (x - g) + 1 print(min(d1, d2))