結果

問題 No.252 "良問"(良問とは言っていない (2)
ユーザー face4face4
提出日時 2019-12-22 17:57:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 432 ms / 2,000 ms
コード長 900 bytes
コンパイル時間 657 ms
コンパイル使用メモリ 76,344 KB
実行使用メモリ 54,892 KB
最終ジャッジ日時 2023-10-12 14:29:29
合計ジャッジ時間 3,893 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 221 ms
4,352 KB
testcase_01 AC 165 ms
4,348 KB
testcase_02 AC 360 ms
13,740 KB
testcase_03 AC 432 ms
54,672 KB
testcase_04 AC 421 ms
54,892 KB
testcase_05 AC 418 ms
54,860 KB
testcase_06 AC 2 ms
4,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<set>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        string s;
        cin >> s;
        multiset<int> cnt;
        int n = s.length();
        vector<int> pro(n, 0);
        for(int i = 4; i+7 <= n; i++){
            int diff = 0;
            for(int j = 0; j < 7; j++)  diff += "problem"[j]!=s[i+j];
            pro[i] = diff;
            cnt.insert(diff);
        }
        int ret = 11, tmp = 0;
        for(int i = 0; i+11 <= n; i++){
            string g = s.substr(i,4);
            int diff = 0;
            for(int j = 0; j < 4; j++)  diff += "good"[j]!=s[i+j];
            ret = min(ret, tmp+diff+(*cnt.begin()));
            cnt.erase(cnt.find(pro[i+4]));
            if(i >= 6){
                if(s.substr(i-6,7)=="problem")  tmp++;
            }
        }
        cout << ret << endl;
    }
    return 0;
}
0