結果

問題 No.599 回文かい
ユーザー ats5515ats5515
提出日時 2017-11-24 23:07:08
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,230 bytes
コンパイル時間 611 ms
コンパイル使用メモリ 84,472 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 11:24:41
合計ジャッジ時間 1,226 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	S.clear();
	
	int N = S.size();
	vector<int> A(N);
	int res = 0;
	vector<int> dp((N / 2) + 2, 0);
	dp[0] = 1;
	int nn = N;
	for (int x = 0; x < nn / 2; x++) {
		N = S.size();
		A[x] = S.size();
		int i = 1, j = 0;
		for (int i = 0; i < N; i++) {
			A[i] = 0;
		}
		while (i < S.size()) {
			while (i + j < S.size() && S[j] == S[i + j]) ++j;
			A[i] = j;
			if (j == 0) { ++i; continue; }
			int k = 1;
			while (i + k < S.size() && k + A[k] < j) A[i + k] = A[k], ++k;
			i += k; j -= k;
		}
		S.pop_back();
		S.erase(S.begin());
	
		for (int k = ((N - 1) / 2) + 1; k < N; k++) {
			if (A[k] == N - k) {
				//cerr << x << " " << x + N - k << endl;
				dp[x + N - k] = (dp[x + N - k] + dp[x]) % MOD;
			}
		}
		//cerr << dp[x] << endl;
		//res = (res + dp[x]) % MOD;
	}
	for (int i = 0; i < dp.size(); i++) {
		//cerr << dp[i] << " ";
		res = (res + dp[i]) % MOD;
	}
	cerr << endl;
	cout << res << endl;
}
0