結果
問題 |
No.1702 count good string
|
ユーザー |
👑 |
提出日時 | 2022-03-23 09:21:03 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 189 ms / 2,000 ms |
コード長 | 698 bytes |
コンパイル時間 | 109 ms |
コンパイル使用メモリ | 6,820 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-11 06:49:42 |
合計ジャッジ時間 | 5,066 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 47 |
ソースコード
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 function solve(n, s, tgt) local t = {} for i = 1, 9 do t[i] = 0 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 = badd(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)