結果

問題 No.150 "良問"(良問とは言っていない
ユーザー kotamanegikotamanegi
提出日時 2016-08-16 20:52:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 1,277 bytes
コンパイル時間 737 ms
コンパイル使用メモリ 85,908 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 09:34:30
合計ジャッジ時間 1,450 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
	}
}
0