結果

問題 No.150 "良問"(良問とは言っていない
ユーザー tetsuzuki1115tetsuzuki1115
提出日時 2018-02-13 05:24:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,375 bytes
コンパイル時間 751 ms
コンパイル使用メモリ 84,664 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 09:46:54
合計ジャッジ時間 1,636 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    int T;
    cin >> T;
    string g = "good";
    string p = "problem";
    vector<string> S(T);
    vector<int> G(101),P(101);
    for ( int i = 0; i < T; i++ ) {
        cin >> S[i];
    }
    for ( int i = 0; i < T; i++ ) {
        for ( int j = 0; j <= S[i].length()-4; j++ ) {
            string s = S[i].substr(j,4);
            int a = 0;
            for ( int k = 0; k < 4; k++ ) {
                if ( s[k] != g[k] ) { a++; }
            }
            G[j] = a;
        }
        for ( int j = 0; j <= S[i].length()-7; j++ ) {
            string s = S[i].substr(j,7);
            int a = 0;
            for ( int k = 0; k < 7; k++ ) {
                if ( s[k] != p[k] ) { a++; }
            }
            P[j] = a;
        }
        int a = INT_MAX;
        for ( int j = S[i].length()-7; j >= 0; j-- ) {
            a = min( a, P[j] );
            P[j] = a;
        }

        int ans = INT_MAX;
        for ( int j = 0; j <= S[i].length()-11; j++ ) {
            ans = min( ans, G[j] + P[j+4] );
        }
        cout << ans << endl;

    }

    return 0;
}
0