結果

問題 No.599 回文かい
コンテスト
ユーザー kriii
提出日時 2018-01-13 15:25:50
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 26 ms / 4,000 ms
コード長 511 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 315 ms
コンパイル使用メモリ 40,312 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-29 21:26:31
合計ジャッジ時間 1,473 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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