結果
問題 |
No.2064 Smallest Sequence on Grid
|
ユーザー |
👑 |
提出日時 | 2022-10-13 12:32:14 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
WA
|
実行時間 | - |
コード長 | 577 bytes |
コンパイル時間 | 385 ms |
コンパイル使用メモリ | 5,632 KB |
実行使用メモリ | 121,216 KB |
最終ジャッジ日時 | 2024-06-26 11:58:25 |
合計ジャッジ時間 | 13,406 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 WA * 17 |
ソースコード
local h, w = io.read("*n", "*n", "*l") local t = {} for i = 1, h do local s = io.read() t[i] = {} for j = 1, w do t[i][j] = s:sub(j, j) end end local ret = {} local last = t[1][1] ret[1] = last for len = 2, h + w - 1 do local nxt = "~" for i = 1, h do local j = len - i if 1 <= j and j <= w and t[i][j] == last then if j < w and t[i][j + 1] < nxt then nxt = t[i][j + 1] end if i < h and t[i + 1][j] < nxt then nxt = t[i + 1][j] end end end table.insert(ret, nxt) last = nxt end print(table.concat(ret))