結果
問題 | No.92 逃走経路 |
ユーザー |
👑 |
提出日時 | 2019-05-06 09:07:09 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 171 ms / 5,000 ms |
コード長 | 1,015 bytes |
コンパイル時間 | 120 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 120,064 KB |
最終ジャッジ日時 | 2024-06-27 02:36:52 |
合計ジャッジ時間 | 1,595 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
local ior = io.input()local n, m, k = ior:read("*n", "*n", "*n")local matrix_list = {}local function make_matrix()local tmp = {}for i = 1, n * n do tmp[i] = 0 endreturn tmpendfor i = 1, m dolocal a, b, c = ior:read("*n", "*n", "*n")if(matrix_list[c] == nil) thenmatrix_list[c] = make_matrix()endmatrix_list[c][(a - 1) * n + b] = 1matrix_list[c][(b - 1) * n + a] = 1endlocal vec = {}for i = 1, n do vec[i] = 1 endlocal mmi = math.minfor i_k = 1, k dolocal mat = matrix_list[ior:read("*n")]local ret_vec = {}for i = 1, n do ret_vec[i] = 0 endfor i = 1, n dofor j = 1, n doret_vec[i] = ret_vec[i] + mat[(i - 1) * n + j] * vec[j]endret_vec[i] = mmi(1, ret_vec[i])endvec = ret_vecendlocal cnt = 0for i = 1, n doif(0 < vec[i]) then cnt = cnt + 1 endendprint(cnt)local fst = truefor i = 1, n doif(0 < vec[i]) thenif(fst) thenfst = falseelseio.write(" ")endio.write(i)endendio.write("\n")