結果

問題 No.150 "良問"(良問とは言っていない
ユーザー memmemmimemmemmi
提出日時 2018-09-14 13:02:13
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 74 ms / 5,000 ms
コード長 1,507 bytes
コンパイル時間 1,116 ms
コンパイル使用メモリ 113,792 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 09:48:30
合計ジャッジ時間 2,192 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 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 74 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 16 ms
5,376 KB
testcase_11 AC 19 ms
5,376 KB
testcase_12 AC 13 ms
5,376 KB
testcase_13 AC 18 ms
5,376 KB
testcase_14 AC 23 ms
5,376 KB
testcase_15 AC 21 ms
5,376 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 AC 7 ms
5,376 KB
testcase_18 AC 19 ms
5,376 KB
testcase_19 AC 23 ms
5,376 KB
testcase_20 AC 24 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

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

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

int hamdis(string s, string t){
    if(s.size()!=t.size())return -1;
    int cnt=0;
    for (int i = 0; i < s.size(); i++) {
        if(s[i]!=t[i])cnt++;
    }
    return cnt;
}

int main() {
    string g = "good";
    string p = "problem";
    int n;
    cin>>n;
    vector<string>str(n);
    for (int i = 0; i < n; i++) {
        cin>>str[i];
    }

    for (int i = 0; i < n; i++) {
        int res = 1000;
        string target = str[i];
        for (int sg = 0; sg < target.size()-10; sg++) {
            for (int sp = sg+4; sp < target.size()-6; sp++) {
                for (int x = 0; x < 4; x++) {
                    target[sg+x]=g[x];
                }
                for (int x = 0; x < 7; x++) {
                    target[sp+x]=p[x];
                }
                res=min(res,hamdis(str[i], target));
                target=str[i];
            }
        }
        cout<<res<<endl;
    }

    return 0;
}
0