結果

問題 No.1702 count good string
ユーザー 👑 obakyanobakyan
提出日時 2022-03-23 09:19:53
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 718 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 6,688 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 14:29:55
合計ジャッジ時間 5,345 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 3 ms
5,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 4 ms
5,376 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 150 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 1 ms
5,376 KB
testcase_47 AC 1 ms
5,376 KB
testcase_48 WA -
testcase_49 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0