結果

問題 No.150 "良問"(良問とは言っていない
ユーザー yuppe19 😺yuppe19 😺
提出日時 2015-12-03 11:04:51
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 1,026 bytes
コンパイル時間 431 ms
コンパイル使用メモリ 59,176 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-19 09:28:57
合計ジャッジ時間 1,164 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,948 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 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,940 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |   int t; scanf("%d", &t);
      |          ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

const int inf = 987654321;

int main(void) {
  int t; scanf("%d", &t);
  for(int cases : range(t)) {
    string s; cin >> s;
    int n = s.size();
    int res = inf;
    for(int i : range(n-3)) {
      for(int j : range(i+4, n-6)) {
        int tmp = (s[i]   != 'g') + 
                  (s[i+1] != 'o') +
                  (s[i+2] != 'o') +
                  (s[i+3] != 'd') +
                  (s[j]   != 'p') +
                  (s[j+1] != 'r') +
                  (s[j+2] != 'o') +
                  (s[j+3] != 'b') +
                  (s[j+4] != 'l') +
                  (s[j+5] != 'e') +
                  (s[j+6] != 'm');
        res = min(res, tmp);
      }
    }
    printf("%d\n", res);
  }
  return 0;
}
0