#line 1 "Main.cpp" #include #include #include #include #include #line 1 "nachia\\string\\enumerate-palindromes.hpp" #line 4 "nachia\\string\\enumerate-palindromes.hpp" namespace nachia{ std::vector EnumeratePalindromes(const std::string& S) { int n = S.size(); if (n == 0) return { 0 }; std::string sx(n * 2 + 1, '$'); for (int i = 0; i < n; i++) sx[i * 2 + 1] = S[i]; n = n * 2 + 1; std::vector res(n); int r = 0; for (int i = 0; i < n; ) { while ((0 <= i - r && i + r < n) ? (sx[i - r] == sx[i + r]) : false) r++; res[i] = r; int di = 1; while ((0 <= i - di && i + di < n) ? (res[i - di] < r - di) : false) { res[i + di] = res[i - di]; di++; } r -= di; i += di; } for (int i = 0; i + 1 < n; i++) res[i] = res[i + 1] - 1; res.resize(n - 2); return res; } } // namespace nachia #line 7 "Main.cpp" using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(int i=0; i<(int)(n); i++) const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; int main(){ string S; cin >> S; auto P = nachia::EnumeratePalindromes(S); int N = S.size(); vector dp(N+1, -1); dp[0] = 1000000; rep(i,P.size()){ for(int c=1-i%2; c<=P[i]; c+=2){ int s = (i-c+1)/2; dp[s+c] = max(dp[s+c], min(dp[s], c)); } } cout << dp[N] << endl; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;