結果

問題 No.150 "良問"(良問とは言っていない
ユーザー ohreitetsuohreitetsu
提出日時 2018-06-29 15:47:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 985 bytes
コンパイル時間 533 ms
コンパイル使用メモリ 69,196 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-13 15:10:55
合計ジャッジ時間 1,895 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//No.150 "良問"(良問とは言っていない
#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 goodMin=4;
		for (i=0;i<=sLen-11;i++){
			k=0;
			int gNum=0;
			for (j=i;j<i+4;j++){
				if (S[j]!=good[k++]){
					gNum++;
				}
			}
			if (goodMin>gNum){
				goodMin=gNum;
			}
		}
		int problemMin=7;
		for (i=4;i<=sLen-7;i++){
			k=0;
			int pNum=0;
			for (j=i;j<i+7;j++){
				if (S[j]!=problem[k++]){
					pNum++;
				}
			}
			if (problemMin>pNum){
				problemMin=pNum;
			}
		}
		cout<<goodMin+problemMin<<endl;
	}
	return 0;
}
0