結果
| 問題 | No.252 "良問"(良問とは言っていない (2) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-04-05 01:02:04 | 
| 言語 | D (dmd 2.109.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,170 bytes | 
| コンパイル時間 | 650 ms | 
| コンパイル使用メモリ | 114,284 KB | 
| 実行使用メモリ | 9,152 KB | 
| 最終ジャッジ日時 | 2024-06-12 18:35:39 | 
| 合計ジャッジ時間 | 1,964 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 4 WA * 3 | 
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;
void main() {
    auto T = readln.chomp.to!int;
    const auto G = "good";
    const auto P = "problem";
    foreach (t; 0..T) {
        auto S = readln.chomp;
        auto N = S.length.to!int;
        int first_problem = 1 << 30;
        auto cnt = new int[](N);
        fill(cnt, 1 << 30);
        foreach (i; 4..N-6) {
            cnt[i] = 0;
            foreach (j; 0..7) {
                if (S[i+j] != P[j]) cnt[i] += 1;
            }
            if (cnt[i] == 0) first_problem = min(i, first_problem);
        }
        foreach (i; iota(N-2, -1, -1)) cnt[i] = min(cnt[i], cnt[i+1]);
        int ans = 1 << 30;
        foreach (i; 0..N-10) {
            int cnt_g = 0;
            foreach (j; 0..4) {
                if (S[i+j] != G[j]) cnt_g += 1;
            }
            if (i < first_problem + 7)
                ans = min(ans, cnt_g + cnt[i]);
            else
                ans = min(ans, cnt_g + cnt[i] + 1);
        }
        ans.writeln;
    }
}
            
            
            
        