結果

問題 No.150 "良問"(良問とは言っていない
ユーザー dnishdnish
提出日時 2018-06-08 14:26:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,110 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 84,740 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 09:47:23
合計ジャッジ時間 1,444 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9+7;

int T;
string s;
int main(){
    cin>>T;
    string s1 = "good";
    string s2 = "problem";
    REP(i,0,T){
        int ans=11;
        cin>>s;
        int n= s.size();
        int good[110] = {};
        int prob[110] = {};
        REP(i,0,n-6){
            REP(j,0,4){
                good[i] += (s[i+j] == s1[j]);
            }

            REP(j,0,7){
                prob[i] += (s[i+j] == s2[j]);
            }
        }
        RREP(i,1,n-6){
            prob[i-1]=max(prob[i-1], prob[i]);
        }
        REP(i,0,n-10){
            ans=min(ans, 11 - good[i] - prob[i+4]);
        }
        p(ans);
    }
    return 0;
}
0