結果

問題 No.150 "良問"(良問とは言っていない
ユーザー くれちーくれちー
提出日時 2017-02-06 20:42:49
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 642 bytes
コンパイル時間 413 ms
コンパイル使用メモリ 21,376 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 09:44:09
合計ジャッジ時間 899 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 5 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 3 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:12:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%d", &t);
      |         ^~~~~~~~~~~~~~~
main.c:16:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |                 scanf("%s", s);
      |                 ^~~~~~~~~~~~~~

ソースコード

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