結果

問題 No.150 "良問"(良問とは言っていない
ユーザー koba-e964koba-e964
提出日時 2015-06-23 14:48:25
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 534 bytes
コンパイル時間 1,613 ms
コンパイル使用メモリ 53,260 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-01 09:54:10
合計ジャッジ時間 1,675 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;

int solve(string s) {
  int l = s.length();
  int ma = 11;
  REP(i, 0, l - 10) {
    REP(j, i + 4, l - 6) {
      int c = 0;
      REP(k, 0, 4) {
	c += s[i + k] != "good"[k];
      }
      REP(k, 0, 7) {
	c += s[j + k] != "problem"[k];
      }
      ma = min(ma, c);
    }
  }
  return ma;
}

int main(void){
  int t;
  cin >> t;
  REP(loop_var, 0, t) {
    string s;
    cin >> s;
    cout << solve(s) << endl;
  }
}
0