結果

問題 No.2064 Smallest Sequence on Grid
ユーザー 👑 obakyanobakyan
提出日時 2022-10-13 12:32:14
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 577 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 5,284 KB
実行使用メモリ 105,828 KB
最終ジャッジ日時 2023-09-08 19:03:13
合計ジャッジ時間 13,955 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 574 ms
105,296 KB
testcase_21 AC 591 ms
105,316 KB
testcase_22 AC 577 ms
105,052 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 554 ms
102,196 KB
testcase_27 WA -
testcase_28 AC 456 ms
101,928 KB
testcase_29 AC 543 ms
105,044 KB
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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))
0