最長回文(hdu 3068)

2022-05-14 18:39:50 字數 927 閱讀 3548

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#include

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

}

view code

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之間由空行...