結果

問題 No.150 "良問"(良問とは言っていない
ユーザー TLwiegehttTLwiegehtt
提出日時 2015-07-15 01:06:56
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 1,122 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 26,144 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-01 09:54:28
合計ジャッジ時間 1,420 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <string.h>


int main(void){
	int in, n;
	scanf("%d", &n);
	for(in=0;in<n;in++){
		char s[110];
		const char good[] = "good";
		const char problem[] = "problem";
		
		int i;
		int hitGood[110]={0};
		int hitProblem[110]={0};
		int sLen, gLen,pLen;
		int ans = 99999;
		
		scanf("%s", s);
		
		sLen = strlen(s);
		gLen = strlen(good);
		pLen = strlen(problem);
		
		for(i=0;i<sLen;i++){
			int j;
			int hit=0;
			
			for( j=0 ; j < gLen ; j++ ){
				if(s[i+j] == '\0'){hit = 0;	break;}
				
				if( good[j] == s[i+j]){
					hit++;
				}
			}
			
			hitGood[i] = hit;
			
			hit = 0;
			for( j=0 ; j < pLen ; j++ ){
				if(s[i+j] == '\0'){hit = 0;	break;}
				
				if( problem[j] == s[i+j]){
					hit++;
				}
			}
			hitProblem[i] = hit;
		}
		
		for(i=0;i<sLen;i++){
			int j,cnt;
			int tmpMinCnt = 99999;
			cnt = (gLen-hitGood[i]);
			
			for(j=(i+gLen); (j+pLen-1)< sLen;j++){
				int tmp = (pLen - hitProblem[j]);
				if( tmp < tmpMinCnt ){
					tmpMinCnt = tmp;
				}
			}
			
			cnt = cnt + tmpMinCnt;
			if(cnt < ans ){
				ans = cnt;
			}
		}
		
		printf("%d\n", ans);
	}
	return 0;
}
0