欢迎光临散文网 会员登陆 & 注册

字符串魔术(主席树 + 回文串)

2023-08-09 15:34 作者:Clayton_Zhou  | 我要投稿

题意:

Problem C. String Magic (Easy Version)

 

Given a string S of length n (indexed from 1 to n) , define f(S) equal to the number of pair (i; j) that:

• 1 <= i < j <= n

• j - i + 1 = 2k; k > 0 (j - i + 1 is even)

• S[i; i + k - 1] = S[i + k; j]

• S[i; i + k - 1] is a palindrome

Here S[L,R] denotes the substring of S with index from L to R.

A palindrome is a string that reads the same from left to right as from right to left.

We need  to calculate f(S).


题解:

主席树 + 回文串


 

in:

3

aaaa

abaaba

ababa

 

out:

4

2


字符串魔术(主席树 + 回文串)的评论 (共 条)

分享到微博请遵守国家法律