結果
| 問題 |
No.599 回文かい
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-12 10:24:36 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 594 bytes |
| コンパイル時間 | 3,018 ms |
| コンパイル使用メモリ | 278,796 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-10-12 10:24:41 |
| 合計ジャッジ時間 | 5,255 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 RE * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, N) for (int i = j; i < N; i++)
const ll mod = 1'000'000'007;
string S;
ll N, dp[1009];
ll dfs(ll pos) {
if (pos * 2 >= N) return dp[pos] = 1;
if (dp[pos] != -1) return dp[pos];
ll res = 0;
rep(i, pos + 1, N / 2 + 1) {
if (S.substr(pos, i - pos) == S.substr(N-i, i - pos)) {
res += dfs(i);
}
}
return dp[pos] = (res + 1LL) % mod;
}
int main() {
cin >> S;
N = S.size();
rep(i, 0, N) dp[i] = -1;
cout << dfs(0) << endl;
return 0;
}