結果
| 問題 |
No.1702 count good string
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2022-03-23 09:19:53 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 718 bytes |
| コンパイル時間 | 52 ms |
| コンパイル使用メモリ | 5,248 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-11 06:49:18 |
| 合計ジャッジ時間 | 5,625 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 16 WA * 31 |
ソースコード
local mod = 1000000007
local function badd(x, y) return (x + y) % mod end
local tgtall = {
"yukicoder",
"?ukicoder",
"y?kicoder",
"yu?icoder",
"yuk?coder",
"yuki?oder",
"yukic?der",
"yukico?er",
"yukicod?r",
"yukicode?"
}
local ret = 0
local inf = 1000000007
local function solve(n, s, tgt)
local t = {}
for i = 1, 9 do
t[i] = inf
end
for i = 1, n do
for j = 1, 9 do
if s:sub(i, i) == tgt:sub(j, j) then
if j == 1 then
t[j] = t[j] + 1
else
t[j] = badd(t[j], t[j - 1])
end
end
end
end
ret = ret + t[9]
end
local n = io.read("*n", "*l")
local s = io.read()
for i = 1, #tgtall do
solve(n, s, tgtall[i])
end
print(ret)