結果
| 問題 |
No.252 "良問"(良問とは言っていない (2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-05-26 14:31:53 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 765 bytes |
| コンパイル時間 | 1,082 ms |
| コンパイル使用メモリ | 139,060 KB |
| 実行使用メモリ | 13,288 KB |
| 最終ジャッジ日時 | 2024-06-12 19:27:16 |
| 合計ジャッジ時間 | 4,312 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 WA * 2 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto t = readln.chomp.to!size_t;
foreach (_; 0..t) calc();
}
void calc()
{
auto s = readln.chomp, sl = s.length;
auto dg = new int[](sl-10), dp = new int[](sl-10);
foreach (i; 0..sl-10) {
dg[i] = dist(s[i..i+4], "good");
dp[i] = dist(s[i+4..i+11], "problem");
}
auto fp = s.indexOf("problem");
foreach (i; 1..sl-10) {
dg[i] = min(dg[i-1], dg[i]);
dp[$-i-1] = min(dp[$-i], dp[$-i-1]);
}
dg[] += dp[];
auto r = int.max;
foreach (i; 0..sl-10) {
if (r > dg[i]) {
r = dg[i];
if (fp >= 0 && i > fp) {
++r;
}
}
}
writeln(r);
}
int dist(string s, string t)
{
return s.zip(t).count!"a[0] != a[1]".to!int;
}