結果
| 問題 |
No.599 回文かい
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2017-11-25 18:34:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,055 bytes |
| コンパイル時間 | 563 ms |
| コンパイル使用メモリ | 84,440 KB |
| 実行使用メモリ | 8,448 KB |
| 最終ジャッジ日時 | 2024-11-27 10:06:02 |
| 合計ジャッジ時間 | 11,521 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 TLE * 2 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 599.cc: No.599 回文かい - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 10000;
const int MAX_HN = MAX_N / 2;
const int MOD = 1000000007;
/* typedef */
typedef long long ll;
/* global variables */
ll dp[MAX_HN + 1];
/* subroutines */
bool kaibunkai(string &s, int n, int i, int j) {
for (int i0 = i, i1 = n - j; i0 < j; i0++, i1++)
if (s[i0] != s[i1]) return false;
return true;
}
/* main */
int main() {
string s;
cin >> s;
int n = s.size(), hn = n / 2;
fill(dp, dp + hn + 1, 1);
for (int i = hn - 1; i >= 0; i--)
for (int j = i + 1; j <= hn; j++)
if (kaibunkai(s, n, i, j)) dp[i] = (dp[i] + dp[j]) % MOD;
printf("%lld\n", dp[0]);
return 0;
}
tnakao0123