結果

問題 No.380 悪の台本
ユーザー nobigomunobigomu
提出日時 2018-09-04 23:19:11
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 1,348 bytes
コンパイル時間 61 ms
コンパイル使用メモリ 5,120 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 06:17:29
合計ジャッジ時間 885 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

local band,lshift,rshift,insert = bit.band,bit.lshift,bit.rshift,table.insert
local D = {
	petit = {"[Nn][Yy][Uu][^%w]*$"; 6};
	digi = {"[Nn][Yy][Oo][^%w]*$"; 6};
	rabi = 0;
	gema = {"[Gg][Ee][Mm][Aa][^%w]*$"; 7};
	piyo = {"[Pp][Yy][Oo][^%w]*$"; 6}
}
D.X = (function (s)
	function loop(i, t)
		local c=1
		while i~=0 do if band(i,1)==1 then insert(t,c) end i,c=rshift(i,1),c+1 end
		return t
	end
	local r,n={},#s
	for i=1,lshift(1,n-1)-1 do
		local t=loop(i,{})
		for s,_ in pairs(D) do
			for _,v in ipairs(t) do s=s:sub(1,v-1)..s:sub(v,v):upper()..s:sub(v+1) end
			r[s]=0
		end
	end
	for i=lshift(1,n-1),lshift(1,n)-1 do
		local t=loop(i,{})
		for _,v in ipairs(t) do s=s:sub(1,v-1)..s:sub(v,v):upper()..s:sub(v+1) end
		r[s]=0
	end
	return r
end)("petit")
do
function f()
	local s=io.stdin:read("*l")
	if s==nil then return nil end
	if D[s:sub(1,4)]~=nil then
		if D[s:sub(1,4)]==0 then
			if s:sub(5):match("%w")==nil then return false end
		else
			if s:sub(-D[s:sub(1,4)][2]):match(D[s:sub(1,4)][1])==nil then return false end
		end
	elseif D[s:sub(1,5)]~=nil then
		if s:sub(-D[s:sub(1,5)][2]):match(D[s:sub(1,5)][1])==nil then return false end
	else return false end
	for e in s:gmatch("%w+") do if D.X[e]~=nil then return false end end
	return true
end
local b=f()
while b~=nil do print(b and "CORRECT (maybe)" or "WRONG!") b=f() end
end
0