Longest palindrome string Related data:
1. Violence Law2. Dynamic Planning3. Center Expansion4. Manacher Method http://blog.csdn.net/ywhorizen/article/details/6629268
http://blog.csdn.net/kangroger/article/details/37742639
The problem that comes up when you look at the suffix array
But it doesn't work. The suffix array is written = = used in a very violent way to get stuck in 1 s
Source Code:
#pragma COMMENT (linker, "/stack:16777216")//for C + + compiler#include <stdio.h> #include <iostream># Include <string> #include <algorithm>using namespace std;string A, res, TMP1, Tmp2;int ans;int main () {int I , J, K, T, N, M; while (Cin >> a) {ans = 1; int len = A.size (); BOOL flag = FALSE; for (i = 0; i < len; ++i) {if (Len-i < ans) break; for (j = len-i; J >= 1;--j) {tmp1 = A.substr (i, j); TMP2 = TMP1; Reverse (Tmp1.begin (), Tmp1.end ()), a if (!flag) {if (Tmp1.compare (tmp2) = = 0 && J & gt;= ans) {flag = true; res = TMP1; Ans = j; Break }} else{if (Tmp1.compare (tmp2) = = 0 && J > ans) {flag = true; res = TMP1; Ans = j; Break }}}} cout << res << Endl; } return 0;}
531 MS is can be over = = but everyone with the suffix array is 15MS too, a little embarrassed AH
Ural 1297 palindrome "longest palindrome string"