結果
問題 | No.150 "良問"(良問とは言っていない |
ユーザー | kotamanegi |
提出日時 | 2016-08-16 20:52:13 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,277 bytes |
コンパイル時間 | 769 ms |
コンパイル使用メモリ | 85,680 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 02:01:30 |
合計ジャッジ時間 | 1,498 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <algorithm> #include <utility> #include <functional> #include <cstring> #include <queue> #include <stack> #include <math.h> #include <iterator> #include <vector> #include <string> #include <set> #include <math.h> #include <iostream> #include<map> #include <stdlib.h> #include <list> #include <typeinfo> #include <list> #include <set> #include <iomanip> using namespace std; #define MAX_MOD 1000000007 #define REP(i,n) for(int i = 0;i < n;++i) string aaa[2] = { "good","problem" }; int main(){ int t; cin >> t; for (int testcase = 0;testcase < t;++testcase) { int go_back[200] = {}; int go_forward[200] = {}; string hoge; cin >> hoge; for (int i = 0;i < hoge.length() - 3;++i) { int tmp = 0; for (int q = 0;q < 4;++q) { if (hoge[i + q] != aaa[0][q]) tmp++; } go_back[i + 4] = tmp; } for (int i = 4;i < hoge.length() - 6;++i) { int tmp = 0; for (int q = 0;q < 7;++q) { if (hoge[i + q] != aaa[1][q]) tmp++; } go_forward[i] = tmp; } int ans = 100; for (int q = 4;q < hoge.length() - 6;++q) { int tmp = 100; for (int j = q;j < hoge.length() - 6;++j) { tmp = min(tmp, go_forward[j]); } ans = min(ans, tmp + go_back[q]); } cout << ans << endl; } }