結果
| 問題 |
No.599 回文かい
|
| コンテスト | |
| ユーザー |
hogehogejapan
|
| 提出日時 | 2022-06-03 11:54:39 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 722 bytes |
| コンパイル時間 | 972 ms |
| コンパイル使用メモリ | 130,048 KB |
| 実行使用メモリ | 13,880 KB |
| 最終ジャッジ日時 | 2024-09-21 02:17:01 |
| 合計ジャッジ時間 | 6,635 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 TLE * 1 -- * 16 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
using ll = unsigned long long;
ll B = pow(10, 9) + 7;
vector<ll> overlap(string s) {
ll n = s.size(), BM = 1;
ll shash = 0, thash = 0;
vector<ll> ans;
for (ll len = 1; len <= n; len++) {
if (len - 1 >= n - len) break;
shash = shash * B + s[len-1];
thash = s[n-len] * BM + thash;
if (shash == thash) ans.push_back(len);
BM *= B;
}
return ans;
}
void solve(const string& s, ll& ans) {
vector<ll> vec = overlap(s);
ll n = s.size();
for (auto len: vec) {
string ns = s.substr(len, n-2*len);
ans++;
solve(ns, ans);
}
}
int main() {
string s; cin >> s;
ll ans = 1;
solve(s, ans);
cout << ans << endl;
}
hogehogejapan