結果
| 問題 |
No.859 路線A、路線B、路線C
|
| コンテスト | |
| ユーザー |
suika_p
|
| 提出日時 | 2019-08-10 00:10:41 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 1,000 ms |
| コード長 | 1,662 bytes |
| コンパイル時間 | 90 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-07-19 16:02:49 |
| 合計ジャッジ時間 | 1,144 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
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
d3 = s - 1 + x + (z - g) + 1
d4 = (y - s) + 1 + x + g - 1
print(min(d1, d2, d3, d4))
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
d3 = s - 1 + x + (z - g) + 1
d4 = (y - s) + 1 + x + g - 1
print(min(d1, d2, d3, d4))
else:
if g < s:
g, s = s, g
d1 = abs(g - s)
d2 = (s - 1) + y + (z - g) + 1
print(min(d1, d2))
suika_p