結果

問題 No.150 "良問"(良問とは言っていない
ユーザー ohreitetsuohreitetsu
提出日時 2018-06-29 16:23:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 1,049 bytes
コンパイル時間 623 ms
コンパイル使用メモリ 68,912 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 09:47:33
合計ジャッジ時間 1,285 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
bool Check(char *pStr)
{
	char *p,*q;
	p=strstr(pStr,"good");
	if (p){
		p++;
		q=strstr(p,"problem");
		if (q){
			return true;
		}
	}
	return false;
}
int main(int argc, char* argv[])
{
	int T;
	cin>>T;
	int l,i,j,k;
	string good="good";
	string problem="problem";
	for (l=0;l<T;l++){
		string S;
		cin>>S;
		if (Check((char*)S.c_str())){
			cout<<0<<endl;
			continue;
		}
		int sLen=S.size();
		int goodproblemMin=11;
		for (i=0;i<=sLen-11;i++){
			int goodMin=4;
			int problemMin=7;
			k=0;
			int gNum=0;
			for (j=i;j<i+4;j++){
				if (S[j]!=good[k++]){
					gNum++;
				}
			}
			if (goodMin>gNum){
				goodMin=gNum;
			}
			for (j=i+4;j<=sLen-7;j++){
				int pNum=0;
				for (k=0;k<7;k++){
					if (S[j+k]!=problem[k]){
						pNum++;
					}
				}
				if (problemMin>pNum){
					problemMin=pNum;
				}
			}
			if (goodproblemMin>goodMin+problemMin){
				goodproblemMin=goodMin+problemMin;
			}
		}
		cout<<goodproblemMin<<endl;
	}
	return 0;
}
0