結果

問題 No.380 悪の台本
ユーザー 👑 obakyanobakyan
提出日時 2020-02-28 11:11:58
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 1,404 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 5,504 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 17:28:48
合計ジャッジ時間 851 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 25 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

local s = io.read()
local function checkCommon(last, word)
  local isok = false
  last = last:lower()
  if 6 < #last then
    last = last:sub(#last - 5, #last)
  end
  if 3 <= #last then
    local pos = last:find(word)
    if pos and 1 <= pos then
      local tmp = true
      for i = pos + 3, #last do
        local num = last:sub(i, i):byte()
        if 97 <= num and num <= 122 then
          tmp = false
        end
      end
      isok = tmp
    end
  end
  return isok
end
while s do
  local accept = false
  local cur = ""
  local sep = {}
  for i = 1, #s do
    local ss = s:sub(i, i)
    if ss == " " then
      table.insert(sep, cur)
      cur = ""
    else
      cur = cur .. ss
    end
  end
  if cur ~= "" then table.insert(sep, cur) end
  local last = sep[#sep]
  if sep[1] == "digi" then
    accept = checkCommon(last, "nyo")
  elseif sep[1] == "petit" then
    accept = checkCommon(last, "nyu")
  elseif sep[1] == "rabi" then
    local found = false
    for i = 2, #sep do
      local w = sep[i]:lower()
      for j = 1, #w do
        local b = w:sub(j, j):byte()
        if 97 <= b and b <= 122 then
          found = true
        end
      end
    end
    accept = found
  elseif sep[1] == "gema" then
    accept = checkCommon(last, "gema")
  elseif sep[1] == "piyo" then
    accept = checkCommon(last, "pyo")
  end
  print(accept and "CORRECT (maybe)" or "WRONG!")
  s = io.read()
end
0