結果

問題 No.599 回文かい
ユーザー okayunonahaokayunonaha
提出日時 2017-11-24 23:11:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 535 bytes
コンパイル時間 1,957 ms
コンパイル使用メモリ 175,072 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2023-08-18 05:12:13
合計ジャッジ時間 7,362 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int n;
string s;
map<pair<int, int> , int> mp;

int solve(int l, int r) {
  int ret = 1;
  string a, b;
  a = "", b = "";
  for (int i = 0; i + l < n / 2; ++i) {
    a += s[l + i], b = s[r - i] + b;    
    if (a == b) {
      ret += (solve(l + i + 1, r - i - 1)) % 1000000007;
    }
  }

  return mp[{l, r}] = ret % 1000000007;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s;
  n = s.size();

  auto ans = solve(0, n - 1);

  cout << ans << endl;

  return 0;
}
0