結果
| 問題 |
No.150 "良問"(良問とは言っていない
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2019-05-05 10:19:53 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 5,000 ms |
| コード長 | 1,108 bytes |
| コンパイル時間 | 174 ms |
| コンパイル使用メモリ | 5,248 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-24 09:28:02 |
| 合計ジャッジ時間 | 1,150 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 |
ソースコード
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