結果

問題 No.150 "良問"(良問とは言っていない
ユーザー yuppe19 😺
提出日時 2015-12-03 11:04:51
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 1,026 bytes
コンパイル時間 465 ms
コンパイル使用メモリ 58,100 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-11 01:58:35
合計ジャッジ時間 1,229 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
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