結果

問題 No.599 回文かい
ユーザー kriiikriii
提出日時 2018-01-13 15:25:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 44 ms / 4,000 ms
コード長 511 bytes
コンパイル時間 1,424 ms
コンパイル使用メモリ 26,288 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-25 15:38:07
合計ジャッジ時間 1,526 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <stdio.h>

int main()
{
	char S[10010];
	scanf("%s", S+1);
	int l = 0;
	while (S[l+1]) l++;
	int n = l / 2;

	const int mod = 1000000007;
	int d[5005] ={ 1, };
	for (int u=2;u<=2*n;u++){
		int as = u / 2, ae = (u + 1) / 2;
		int bs = l + 1 - ae, be = l + 1 - as;
		while (1 <= as && ae <= n && S[as] == S[bs] && S[ae] == S[be]){
			d[ae] = (d[ae] + d[as-1]) % mod;
			as--; ae++;
			bs--; be++;
		}
	}

	int ans = 0;
	for (int i=0;i<=n;i++) ans = (ans + d[i]) % mod;
	printf("%d\n", ans);

	return 0;
}
0