結果
| 問題 |
No.1344 Typical Shortest Path Sum
|
| コンテスト | |
| ユーザー |
tnodino
|
| 提出日時 | 2022-05-06 18:59:59 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 592 bytes |
| コンパイル時間 | 227 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 76,800 KB |
| 最終ジャッジ日時 | 2024-07-05 20:03:54 |
| 合計ジャッジ時間 | 6,285 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 14 WA * 63 |
ソースコード
def BellmanFord(N, G, s):
INF = 1<<64
dist = [INF for _ in range(N)]
dist[s] = 0
for cnt in range(N):
Update = False
for pos,nxt,cost in G:
if dist[pos] + cost < dist[nxt]:
dist[nxt] = dist[pos] + cost
Update = True
if not Update:
break
if cnt == N - 1:
return -1
return dist
N,M = map(int,input().split())
G = []
for _ in range(M):
s,t,d = map(int,input().split())
s -= 1
t -= 1
G.append((s, t, d))
for i in range(N):
print(sum(BellmanFord(N, G, i)))
tnodino