結果
| 問題 | No.599 回文かい |
| コンテスト | |
| ユーザー |
illanasty
|
| 提出日時 | 2021-12-20 10:06:03 |
| 言語 | C++17(clang) (17.0.6 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,440 bytes |
| 記録 | |
| コンパイル時間 | 3,592 ms |
| コンパイル使用メモリ | 141,552 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 15:15:03 |
| 合計ジャッジ時間 | 10,345 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 WA * 15 |
ソースコード
#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;
}
illanasty