結果

問題 No.150 "良問"(良問とは言っていない
ユーザー kriiikriii
提出日時 2018-12-08 21:21:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 779 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 33,664 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 09:48:40
合計ジャッジ時間 900 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

char S[101];
int L[101],R[101];

int main()
{
	int Test; scanf("%d", &Test); while (Test--){
		scanf ("%s",S);

		int l = 0;
		while (S[l]) l++;

		for (int i=3;i<l;i++){
			int c = 0;
			c += S[i-3] != 'g';
			c += S[i-2] != 'o';
			c += S[i-1] != 'o';
			c += S[i-0] != 'd';
			L[i] = c;
		}
		for (int i=0;i<l-6;i++){
			int c = 0;
			c += S[i+0] != 'p';
			c += S[i+1] != 'r';
			c += S[i+2] != 'o';
			c += S[i+3] != 'b';
			c += S[i+4] != 'l';
			c += S[i+5] != 'e';
			c += S[i+6] != 'm';
			R[i] = c;
		}
		for (int i=4;i<l;i++) if (L[i] > L[i-1]) L[i] = L[i-1];
		for (int i=l-8;i>=0;i--) if (R[i] > R[i+1]) R[i] = R[i+1];

		int ans = l;
		for (int i=3;i<l-7;i++) if (ans > L[i] + R[i+1]) ans = L[i] + R[i+1];
		printf ("%d\n",ans);
	}

	return 0;
}
0