結果
| 問題 |
No.599 回文かい
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-12 10:10:51 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 587 bytes |
| コンパイル時間 | 2,871 ms |
| コンパイル使用メモリ | 276,432 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-10-12 10:10:56 |
| 合計ジャッジ時間 | 4,850 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 WA * 4 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[509];
ll dfs(ll pos) {
if (pos * 2 >= N) return dp[pos] = 1;
if (dp[pos] != -1) return dp[pos];
ll res = 0;
rep(i, 1, N/2 - pos + 1) {
if (S.substr(pos, i) == S.substr(N-pos-i, i)) {
res += dfs(pos + i);
}
}
return dp[pos] = res + 1;
}
int main() {
cin >> S;
N = S.size();
rep(i, 0, N / 2 + 1) dp[i] = -1;
cout << dfs(0) << endl;
return 0;
}