結果

問題 No.599 回文かい
ユーザー hogehogejapanhogehogejapan
提出日時 2022-06-03 11:54:39
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 722 bytes
コンパイル時間 1,333 ms
コンパイル使用メモリ 119,784 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-21 01:27:08
合計ジャッジ時間 7,806 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
evil_0.txt -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0