結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2020-02-28 11:23:17 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 1,000 ms |
| コード長 | 1,644 bytes |
| コンパイル時間 | 40 ms |
| コンパイル使用メモリ | 6,692 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-13 16:23:38 |
| 合計ジャッジ時間 | 722 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 |
ソースコード
local s = io.read()
local function checkCommon(last, word)
local isok = false
last = last:lower()
if 7 < #last then
last = last:sub(#last - 6, #last)
end
local pos = last:find(word)
if pos and 1 <= pos then
local tmp = true
local cnt = 0
for i = pos + #word, #last do
local num = last:sub(i, i):byte()
if (97 <= num and num <= 122) or (48 <= num and num <= 57) then
tmp = false
else
cnt = cnt + 1
end
end
if 3 < cnt then tmp = false end
isok = tmp
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
if cur ~= "" or #sep == 0 then
table.insert(sep, cur)
end
cur = ""
else
cur = cur .. ss
end
end
if cur ~= "" then table.insert(sep, cur) end
local last = ""
if #sep == 2 then last = sep[#sep]
elseif 2 < #sep then last = sep[#sep - 1] .. sep[#sep] end
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) or (48 <= b and b <= 57) 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