problem description
給出乙個只由小寫英文本元a,b,c...y,z
組成的字串s,求
s中最長回文串的長度
.回文就是正反讀都是一樣的字串,如
aba, abba
等input
輸入有多組case,
不超過120組,
每組輸入為一行小寫英文本元
a,b,c...y,z
組成的字串
s,兩組case
之間由空行隔開
(該空行不用處理
),字串長度len <= 110000
output
每一行乙個整數x,
對應一組
case,
表示該組
case
的字串中所包含的最長回文長度
.sample input
aaaa
abab
sample output
#include#includeview code#include
#define m 220010
using
namespace
std;
char
s,s1[m],s2[m];
intn,p[m];
void
manacher()
ans=max(ans,p[i]-1
); }
printf(
"%d\n
",ans);
}void
init()
intmain()
return0;
}
HDU 3068 最長回文
題 目 鏈 接 看完後自己寫了一遍,感覺真的是很神奇的結論啊!本來這題看到可以用字尾陣列來寫的,但沒有學過,去看了一下,真心給暈了,決定找個機會認真研究下。我的 include include includeusing namespace std define min a,b a b a b cha...
HDU 3068 最長回文
存在o n 的演算法,學習了一下 include include includeusing namespace std const int maxn 300011 int n,p maxn char str maxn in maxn int main str 0 str 1 n n 2 2 str ...
HDU 3068 最長回文
problem description 給出乙個只由小寫英文本元a,b,c.y,z組成的字串s,求s中最長回文串的長度.回文就是正反讀都是一樣的字串,如aba,abba等 input 輸入有多組case,不超過120組,每組輸入為一行小寫英文本元a,b,c.y,z組成的字串s 兩組case之間由空行...