結果

問題 No.150 "良問"(良問とは言っていない
ユーザー ry0u_ydry0u_yd
提出日時 2015-09-04 02:06:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 995 bytes
コンパイル時間 573 ms
コンパイル使用メモリ 68,764 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 09:26:51
合計ジャッジ時間 1,358 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
    int t;
    cin >> t;

    rep(q,t) {
        string s;
        cin >> s;

        int n = s.size();
        string g = "good", p = "problem";

        int ans = INF;
        rep(i,n) {
            REP(j,i+4,n-6) {
                int cnt = 0;

                string t = s.substr(i,4);
                rep(k,4) {
                    if(t[k] != g[k]) cnt++;

                }

                string t2 = s.substr(j,7);
                rep(k,7) {
                    if(t2[k] != p[k]) cnt++;
                }

                ans = min(ans,cnt);
            }
        }

        cout << ans << endl;
    }

    return 0;
}
0