結果
| 問題 |
No.807 umg tours
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2019-04-28 21:42:12 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 938 bytes |
| コンパイル時間 | 499 ms |
| コンパイル使用メモリ | 5,504 KB |
| 実行使用メモリ | 32,752 KB |
| 最終ジャッジ日時 | 2024-11-23 19:29:14 |
| 合計ジャッジ時間 | 10,637 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 TLE * 1 |
ソースコード
ior = io.read
local n, m = ior("*n", "*n")
local costs = {}
for i = 1, n do costs[i] = {} end
for i = 1, m do
local a, b, c = ior("*n", "*n", "*n")
costs[a][b], costs[b][a] = c, c
end
local inf = 99999999999999
local straight = {}
local warp = {}
straight[1], warp[1] = 0, 0
for i = 2, n do straight[i], warp[i] = inf, inf end
local cue = {}
cue[1] = 1
local done, tasks = 0, 1
local mmi = math.min
while(done < tasks) do
done = done + 1
local src = cue[done]
for k, v in pairs(costs[src]) do
local added = false
if(straight[src] + v < straight[k]) then
straight[k] = straight[src] + v
added = true
tasks = tasks + 1
table.insert(cue, k)
end
local w = mmi(warp[src] + v, straight[src])
if(w < warp[k]) then
warp[k] = w
if(not added) then
tasks = tasks + 1
table.insert(cue, k)
end
end
end
end
for i = 1, n do
print(straight[i] + warp[i])
end