結果
| 問題 |
No.859 路線A、路線B、路線C
|
| コンテスト | |
| ユーザー |
ntuda
|
| 提出日時 | 2025-02-20 23:09:35 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 918 bytes |
| コンパイル時間 | 377 ms |
| コンパイル使用メモリ | 82,232 KB |
| 実行使用メモリ | 53,752 KB |
| 最終ジャッジ日時 | 2025-02-20 23:09:37 |
| 合計ジャッジ時間 | 1,778 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 1 |
ソースコード
XYZ = list(map(int,input().split()))
ST = []
dic = {"A":0,"B":1,"C":2}
for i in range(2):
s,t = input().split()
t = int(t) - 1
ST.append((s,t))
UV = [(0,1,1),(0,2,1),(1,2,1),(3,4,1),(4,5,1),(3,5,1),
(0,3,XYZ[0]-1),(1,4,XYZ[1]-1),(2,5,XYZ[2]-1)]
if ST[0][0] == ST[1][0]:
s, t1 = ST[0]
t2 = ST[1][1]
s = dic[s]
UV.append((s,6,t1))
UV.append((s + 3,7,XYZ[s] - t2 - 1))
UV.append((6,7,abs(t1-t2)))
else:
s, t = ST[0]
s = dic[s]
UV.append((s,6,t))
UV.append((s + 3,6,XYZ[s] - t - 1))
s, t = ST[1]
s = dic[s]
UV.append((s,7,t))
UV.append((s + 3,7,XYZ[s] - t - 1))
E = [[] for _ in range(8)]
for u, v, c in UV:
E[u].append((v,c))
E[v].append((u,c))
INF = 10 ** 10
dp = [INF] * 8
dp[6] = 0
Q = [6]
while Q:
x = Q.pop()
for y,t in E[x]:
if dp[y] > dp[x] + t:
dp[y] = dp[x] + t
Q.append(y)
print(dp[7])
ntuda