結果
| 問題 |
No.150 "良問"(良問とは言っていない
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-08 15:07:25 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 612 bytes |
| コンパイル時間 | 2,038 ms |
| コンパイル使用メモリ | 160,188 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-11-08 15:07:28 |
| 合計ジャッジ時間 | 3,563 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 |
ソースコード
module main;
import std;
// 文字列SとTのうち、異なる文字の個数を返す
int check(string S, string T)
{
assert(S.length == T.length);
int res = 0;
foreach (i; 0 .. S.length)
res += S[i] != T[i];
return res;
}
void main()
{
// クエリの処理
foreach (_; 0 .. readln.chomp.to!int) {
auto S = readln.chomp;
auto len = S.length;
int ans = 10 ^^ 9;
foreach (i; 0 .. len - 10) {
int n1 = check(S[i .. i + 4], "good"), n2 = 10 ^^ 9;
foreach (j; i + 4 .. len - 6) {
n2 = min(n2, check(S[j .. j + 7], "problem"));
}
ans = min(ans, n1 + n2);
}
writeln(ans);
}
}