結果

問題 No.599 回文かい
ユーザー koyumeishikoyumeishi
提出日時 2016-06-03 20:15:45
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,919 ms / 4,000 ms
コード長 456 bytes
コンパイル時間 849 ms
コンパイル使用メモリ 69,744 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 23:46:15
合計ジャッジ時間 7,010 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 8 ms
5,376 KB
testcase_11 AC 6 ms
5,376 KB
testcase_12 AC 15 ms
5,376 KB
testcase_13 AC 17 ms
5,376 KB
testcase_14 AC 1,197 ms
5,376 KB
testcase_15 AC 80 ms
5,376 KB
testcase_16 AC 1,630 ms
5,376 KB
testcase_17 AC 1,919 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
evil_0.txt AC 480 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
using namespace std;

const long long mod = 1000000007;

int main(){
	string s;
	cin >> s;
	int n = s.size();
	vector<long long> dp(n+1, 0);
	dp[0] = 1;

	long long ans = 1;
	for(int i=1; i<=n/2; i++){
		for(int j=0; j<i; j++){
			if(!dp[j]) continue;
			if(s.substr(j, i-j) == s.substr(n-i,i-j)){
				(dp[i] += dp[j]) %= mod;
			}
		}
		(ans += dp[i]) %= mod;
	}

	printf("%lld", ans);
	return 0;
}
0