結果

問題 No.150 "良問"(良問とは言っていない
ユーザー mayoko_mayoko_
提出日時 2015-02-12 23:53:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 1,180 bytes
コンパイル時間 570 ms
コンパイル使用メモリ 73,524 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-01 09:45:09
合計ジャッジ時間 1,525 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;
typedef long long ll;

const int goodNumber = 4;
const int problemNumber = 7;

int solve(const string &s) {
    int ret = 1000;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        for (int j = i+goodNumber; j <= n-problemNumber; j++) {
            int val = 0;
            if (s[i] != 'g') val++;
            if (s[i+1] != 'o') val++;
            if (s[i+2] != 'o') val++;
            if (s[i+3] != 'd') val++;
            if (s[j] != 'p') val++;
            if (s[j+1] != 'r') val++;
            if (s[j+2] != 'o') val++;
            if (s[j+3] != 'b') val++;
            if (s[j+4] != 'l') val++;
            if (s[j+5] != 'e') val++;
            if (s[j+6] != 'm') val++;
            ret = min(ret, val);
        }
    }
    return ret;
}

int main(void) {
    int T;
    cin >> T;
    while (T--) {
        string s;
        cin >> s;
        cout << solve(s) << endl;
    }
    return 0;
}
0