結果
問題 | No.1292 パタパタ三角形 |
ユーザー |
👑 |
提出日時 | 2020-11-24 23:22:39 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 60 ms / 2,000 ms |
コード長 | 891 bytes |
コンパイル時間 | 454 ms |
コンパイル使用メモリ | 7,072 KB |
実行使用メモリ | 16,128 KB |
最終ジャッジ日時 | 2024-07-23 18:53:32 |
合計ジャッジ時間 | 1,952 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
local s = io.read()local t = {}t[0] = {}t[0][0] = truelocal row, col = 0, 0local top, left, right = 1, 2, 3local bottom = 0local ret = 1local function register()if not t[row] then t[row] = {} endif not t[row][col] then ret = ret + 1 endt[row][col] = trueendfor i = 1, #s dolocal b = s:byte(i) - 96if i % 2 == 1 thenif top == b thenbottom = toprow = row - 1elseif left == b thenleft, right, bottom = top, left, rightcol = col - 1else--if right == b thenleft, right, bottom = right, top, leftcol = col + 1endelseif bottom == b thentop = bottomrow = row + 1elseif left == b thenleft, right, top = bottom, left, rightcol = col - 1else--if right == b thenleft, right, top = right, bottom, leftcol = col + 1endendregister()endprint(ret)