CF159D.Palindrome pairs

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a non-empty string ss consisting of lowercase letters. Find the number of pairs of non-overlapping palindromic substrings of this string.

In a more formal way, you have to find the quantity of tuples (a,b,x,y)(a,b,x,y) such that 1<=a<=b<x<=y<=|s| and substrings s[a... b]s[a...\ b] , s[x... y]s[x...\ y] are palindromes.

A palindrome is a string that can be read the same way from left to right and from right to left. For example, "abacaba", "z", "abba" are palindromes.

A substring s[i... j]s[i...\ j] ( 1<=i<=j<=s1<=i<=j<=|s| ) of string ss = s1s2... sss_{1}s_{2}...\ s_{|s|} is a string sisi+1... sjs_{i}s_{i+1}...\ s_{j} . For example, substring s[2...4]s[2...4] of string ss = "abacaba" equals "bac".

输入格式

The first line of input contains a non-empty string ss which consists of lowercase letters ('a'...'z'), ss contains at most 20002000 characters.

输出格式

Output a single number — the quantity of pairs of non-overlapping palindromic substrings of ss .

Please do not use the %lld format specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d format specifier.

输入输出样例

  • 输入#1

    aa
    

    输出#1

    1
    
  • 输入#2

    aaa
    

    输出#2

    5
    
  • 输入#3

    abacaba
    

    输出#3

    36
    
首页