結果
| 問題 | 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] = true
local row, col = 0, 0
local top, left, right = 1, 2, 3
local bottom = 0
local ret = 1
local function register()
  if not t[row] then t[row] = {} end
  if not t[row][col] then ret = ret + 1 end
  t[row][col] = true
end
for i = 1, #s do
  local b = s:byte(i) - 96
  if i % 2 == 1 then
    if top == b then
      bottom = top
      row = row - 1
    elseif left == b then
      left, right, bottom = top, left, right
      col = col - 1
    else--if right == b then
      left, right, bottom = right, top, left
      col = col + 1
    end
  else
    if bottom == b then
      top = bottom
      row = row + 1
    elseif left == b then
      left, right, top = bottom, left, right
      col = col - 1
    else--if right == b then
      left, right, top = right, bottom, left
      col = col + 1
    end
  end
  register()
end
print(ret)
            
            
            
        