結果

問題 No.150 "良問"(良問とは言っていない
ユーザー くれちーくれちー
提出日時 2017-02-06 20:42:49
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 642 bytes
コンパイル時間 877 ms
コンパイル使用メモリ 24,908 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-01 10:12:14
合計ジャッジ時間 1,784 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#define rep(i, n) for (i = 0; i < n; i++)
#define min(a, b) (a < b ? a : b)
#define inf 1145141919

int main() {
	char *good = "good";
	char *problem = "problem";

	int i, j, t;
	scanf("%d", &t);

	rep(i, t) {
		char s[101];
		scanf("%s", s);
		int len = strlen(s);
		int top1 = 0, top2 = len - 7;
		int ans = inf;
		while (top1 <= len - 11) {
			int t1 = 0, t2 = 0;
			rep(j, 4) if (s[top1 + j] != good[j]) t1++;
			rep(j, 7) if (s[top2 + j] != problem[j]) t2++;
			ans = min(ans, t1 + t2);
			if (top1 + 4 == top2) { top1++; top2 = len - 7; }
			else top2--;
		}
		printf("%d\n", ans);
	}
	return 0;
}
0