結果

問題 No.150 "良問"(良問とは言っていない
ユーザー 👑 obakyanobakyan
提出日時 2019-05-05 10:19:53
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 1,108 bytes
コンパイル時間 56 ms
コンパイル使用メモリ 5,336 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 15:03:09
合計ジャッジ時間 1,567 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 12 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 AC 5 ms
4,380 KB
testcase_15 AC 5 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 5 ms
4,380 KB
testcase_19 AC 5 ms
4,376 KB
testcase_20 AC 5 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local t = io.read("*n", "*l")
for i = 1, t do
  local minmodcount = 100
  local str = io.read()
  local n = #str
  for j = 1, n - 10 do
    local jmodcount = 0
    if(str:sub(j, j) ~= "g") then jmodcount = jmodcount + 1 end
    if(str:sub(j + 1, j + 1) ~= "o") then jmodcount = jmodcount + 1 end
    if(str:sub(j + 2, j + 2) ~= "o") then jmodcount = jmodcount + 1 end
    if(str:sub(j + 3, j + 3) ~= "d") then jmodcount = jmodcount + 1 end
    for k = j + 4, n - 6 do
      local kmodcount = 0
      if(str:sub(k, k) ~= "p") then kmodcount = kmodcount + 1 end
      if(str:sub(k + 1, k + 1) ~= "r") then kmodcount = kmodcount + 1 end
      if(str:sub(k + 2, k + 2) ~= "o") then kmodcount = kmodcount + 1 end
      if(str:sub(k + 3, k + 3) ~= "b") then kmodcount = kmodcount + 1 end
      if(str:sub(k + 4, k + 4) ~= "l") then kmodcount = kmodcount + 1 end
      if(str:sub(k + 5, k + 5) ~= "e") then kmodcount = kmodcount + 1 end
      if(str:sub(k + 6, k + 6) ~= "m") then kmodcount = kmodcount + 1 end
      minmodcount = math.min(minmodcount, kmodcount + jmodcount)
    end
  end
  print(minmodcount)
end
0