結果

問題 No.150 "良問"(良問とは言っていない
ユーザー GOTKAKO
提出日時 2025-07-23 11:31:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 585 bytes
コンパイル時間 2,193 ms
コンパイル使用メモリ 196,024 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-07-23 11:31:25
合計ジャッジ時間 3,374 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T; cin >> T;
    string g = "good",p = "problem";
    while(T--){
        string s; cin >> s;
        int N = s.size();
        int answer = 1000;
        for(int i=0; i<=N-11; i++) for(int k=i+4; k<=N-7; k++){
            int now = 0;
            for(int l=0; l<4; l++) if(s.at(i+l) != g.at(l)) now++;
            for(int l=0; l<7; l++) if(s.at(k+l) != p.at(l)) now++;
            answer = min(answer,now);
        }
        cout << answer << "\n";
    }
}
0