結果

問題 No.252 "良問"(良問とは言っていない (2)
ユーザー IL_mstaIL_msta
提出日時 2015-07-25 00:04:59
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,585 bytes
コンパイル時間 1,015 ms
コンパイル使用メモリ 87,148 KB
実行使用メモリ 5,148 KB
最終ジャッジ日時 2023-09-23 01:42:04
合計ジャッジ時間 6,681 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1,989 ms
4,376 KB
testcase_03 AC 20 ms
5,108 KB
testcase_04 AC 15 ms
5,148 KB
testcase_05 AC 1,337 ms
5,100 KB
testcase_06 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
#include <sstream>
 
#include <algorithm>
#include <cmath>
 
#include <string>
//#include <array>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
 
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
int ans[100000];

bool check(string str){
	int a,b;
	a = str.find("good");
	if(a == -1){
		return false;
	}
	b = str.find("problem",a);
	if( b == -1){
		return false;
	}
	return true;
}

int solve(string str){
	//goodp roble m
	int LenA,LenB;
	int ans=12,tans;
	for(int i=0;i<=str.size()-11;++i){
		LenA = 0;
		if(str[i  ] != 'g')LenA++;
		if(str[i+1] != 'o')LenA++;
		if(str[i+2] != 'o')LenA++;
		if(str[i+3] != 'd')LenA++;
		if(ans <= LenA) continue;
		for(int j=i+4;j<=str.size()-7;++j){
			LenB = 0;
			if(str[j  ] != 'p')LenB++;
			if(str[j+1] != 'r')LenB++;
			if(str[j+2] != 'o')LenB++;
			if(str[j+3] != 'b')LenB++;
			if(str[j+4] != 'l')LenB++;
			if(str[j+5] != 'e')LenB++;
			if(str[j+6] != 'm')LenB++;
			tans = LenA+LenB;
			ans = min(ans,tans);
			if(ans == 0){
				break;
			}
		}
	}

	return ans;
}
int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(16);//
	
	int T;
	cin>>T;
	string str;
	rep(i,T){
		cin>>str;
		ans[i] = solve(str);
	}
	rep(i,T){
		P(ans[i]);
	}
	return 0;
}
0