結果
| 問題 |
No.599 回文かい
|
| コンテスト | |
| ユーザー |
okayunonaha
|
| 提出日時 | 2017-11-24 23:11:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 535 bytes |
| コンパイル時間 | 1,522 ms |
| コンパイル使用メモリ | 176,020 KB |
| 実行使用メモリ | 13,644 KB |
| 最終ジャッジ日時 | 2024-11-27 08:01:22 |
| 合計ジャッジ時間 | 62,354 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 TLE * 12 |
ソースコード
#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;
}
okayunonaha