結果

問題 No.599 回文かい
ユーザー _____Yuto___
提出日時 2017-11-25 00:49:54
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 563 bytes
コンパイル時間 526 ms
コンパイル使用メモリ 56,784 KB
実行使用メモリ 19,968 KB
最終ジャッジ日時 2024-11-27 08:56:49
合計ジャッジ時間 2,734 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 RE * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <string.h>
#include <iostream>
#include <string>
using namespace std;

#define MOD (int)(1e9 + 7)

typedef long long ll;

ll memo[1000][1000];

int solve(string s, int k)
{
  ll ret = 1, n = s.length();
  if(memo[k][n] != -1) return memo[k][n];
  for(int i = 1; i <= n / 2; i++){
    if(s.substr(0, i) == s.substr(n - i, i)){
      ret += solve(s.substr(i, n - 2 * i), k + i);
      ret %= MOD;
    }
  }
  return memo[k][n] = ret;
}

int main()
{
  string s;
  cin >> s;

  memset(memo, -1, sizeof(memo));

  cout << solve(s, 1) << endl;

  return 0;
}
0