結果
問題 | No.1814 Uribo Road (Easy) |
ユーザー | 👑 obakyan |
提出日時 | 2022-01-15 21:51:14 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
AC
|
実行時間 | 56 ms / 2,000 ms |
コード長 | 1,909 bytes |
コンパイル時間 | 165 ms |
コンパイル使用メモリ | 6,940 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-05-01 20:27:05 |
合計ジャッジ時間 | 2,497 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 3 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 4 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 4 ms
5,376 KB |
testcase_12 | AC | 8 ms
5,376 KB |
testcase_13 | AC | 6 ms
5,376 KB |
testcase_14 | AC | 10 ms
5,376 KB |
testcase_15 | AC | 21 ms
5,376 KB |
testcase_16 | AC | 36 ms
5,376 KB |
testcase_17 | AC | 39 ms
5,376 KB |
testcase_18 | AC | 38 ms
5,376 KB |
testcase_19 | AC | 38 ms
5,376 KB |
testcase_20 | AC | 39 ms
5,376 KB |
testcase_21 | AC | 39 ms
5,376 KB |
testcase_22 | AC | 43 ms
5,376 KB |
testcase_23 | AC | 43 ms
5,376 KB |
testcase_24 | AC | 41 ms
5,376 KB |
testcase_25 | AC | 40 ms
5,376 KB |
testcase_26 | AC | 47 ms
5,376 KB |
testcase_27 | AC | 56 ms
5,376 KB |
testcase_28 | AC | 53 ms
5,376 KB |
testcase_29 | AC | 52 ms
5,376 KB |
testcase_30 | AC | 53 ms
5,376 KB |
testcase_31 | AC | 54 ms
5,376 KB |
testcase_32 | AC | 9 ms
5,376 KB |
testcase_33 | AC | 3 ms
5,376 KB |
testcase_34 | AC | 2 ms
5,376 KB |
testcase_35 | AC | 11 ms
5,376 KB |
testcase_36 | AC | 5 ms
5,376 KB |
testcase_37 | AC | 7 ms
5,376 KB |
testcase_38 | AC | 14 ms
5,376 KB |
testcase_39 | AC | 5 ms
5,376 KB |
testcase_40 | AC | 7 ms
5,376 KB |
testcase_41 | AC | 45 ms
5,376 KB |
testcase_42 | AC | 26 ms
5,376 KB |
testcase_43 | AC | 7 ms
5,376 KB |
testcase_44 | AC | 14 ms
5,376 KB |
testcase_45 | AC | 4 ms
5,376 KB |
testcase_46 | AC | 42 ms
5,376 KB |
ソースコード
local mfl, mce = math.floor, math.ceil local bls, brs = bit.lshift, bit.rshift local mmi, mma = math.min, math.max local n, m, k = io.read("*n", "*n", "*n") local r = {} for i = 1, k do r[i] = io.read("*n") end local inf = 1000000007 local edge = {} local len = {} for i = 1, n do edge[i] = {} len[i] = {} for j = 1, n do len[i][j] = inf end len[i][i] = 0 end local ea, eb, ec = {}, {}, {} for i = 1, m do local a, b, c = io.read("*n", "*n", "*n") ea[i], eb[i], ec[i] = a, b, c table.insert(edge[a], i) table.insert(edge[b], i) len[a][b] = mmi(len[a][b], c) len[b][a] = len[a][b] end for z = 1, n do for i = 1, n do for j = 1, n do len[i][j] = mmi(len[i][j], len[i][z] + len[z][j]) end end end local bittot = bls(1, k) local waytot = 1 for i = 1, k do waytot = waytot * i end local function getpattern(n, patall, idx) local used = {} local retary = {} local div = patall for i = 1, n do used[i] = false end for i = n, 1, -1 do div = mfl(div / i) local v_idx = mfl(idx / div) idx = idx % div local tmp_idx = 0 for j = 1, n do if not used[j] then if tmp_idx == v_idx then table.insert(retary, j) used[j] = true break else tmp_idx = tmp_idx + 1 end end end end return retary end for i = 1, n do -- print(table.concat(len[i], " ")) end local ret = inf * inf for i = 0, waytot - 1 do local ary = getpattern(k, waytot, i) for j = 0, bittot - 1 do local tj = j local q = 0 local pos = 1 for z = 1, k do local d1, d2 = false, false if tj % 2 == 0 then d1, d2 = ea[r[ary[z]]], eb[r[ary[z]]] else d2, d1 = ea[r[ary[z]]], eb[r[ary[z]]] end q = q + len[pos][d1] + ec[r[ary[z]]] pos = d2 tj = brs(tj, 1) end q = q + len[pos][n] ret = mmi(ret, q) end end print(ret)