結果

問題 No.599 回文かい
ユーザー illanastyillanasty
提出日時 2021-12-20 10:06:03
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,440 bytes
コンパイル時間 1,681 ms
コンパイル使用メモリ 106,928 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-13 19:28:04
合計ジャッジ時間 10,315 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>


using namespace std;


using ull = unsigned long long;
using ll = long long;
using ld = long double;


#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)


template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
template<class T> using pq  = priority_queue<T>;


template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return true; } return false; }


constexpr int MOD = 1000000007;


string s;
int n;
int memo[10005];


int dp(int l, int r) {
  if (r - l <= 1) return 1LL;
  if (memo[l] != -1) return memo[l];

  int& ret = memo[l];
  ret = 1;

  for (int l2 = l+1, r2 = r-1; l2 <= r2; ++l2, --r2) {
    if (s.substr(l, l2) == s.substr(r2, r)) {
      ret += dp(l2, r2);
      ret %= MOD;
    }
  }

  return ret;
}


int main() {
  cin >> s;
  n = s.size();

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

  cout << dp(0, n) << endl;
  return 0;
}
0