아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Repetitive String Invention

시간 제한2초메모리 제한2048 MB

요약
순서를 지켜 겹치지 않게 고른 두 부분 문자열의 이어붙이기가 같은 두 반쪽으로 이루어질 때, 그 경우의 수를 센다.
난이도

보통10점 중 7점

유형
문자열, 동적 계획법, 문자열 매칭
정답자
아직 제출이 없습니다

문제

Lulu has a string consisting of lowercase English letters. She would like to make her string Repetitive. A repetitive string has an even number of characters, and the first half of the string exactly matches the second half of the string. For example, "lulu", "abcabc" and "xx" are repetitive strings, while "xyx" and "abac" are not.

To get a repetitive string, Lulu can take two non-overlapping, non-empty substrings from her string and concatenate them together. The substrings must be concatenated in the order that they appear in her string.

She's wondering, what is the number of ways she can choose two substrings to make a repetitive string? Two ways are different if at least one of the substrings Lulu uses comes from a different part of her string.

Consider the string "aaaa".

  • There are six ways for Lulu to form the repetitive string "aa": by matching each "a" with each subsequent "a" (11+22, 11+33, 11+44, 22+33, 22+44, 33+44).
  • There are also three ways for her to form "aaaa": "a"+"aaa", "aa"+"aa" and "aaa"+"a".

So there are nine ways for Lulu to form a repetitive string by concatenating non-overlapping, non-empty substrings of "aaaa" in order.

입력

The single line of input contains a single string ss (1≤∣s∣≤800,s∈∗∗a∗∗−∗∗z∗∗\*1 \le |s| \le 800, s \in \\{**a**-**z**\\}^\*). This is Lulu's string.

출력

Output a single integer, which is the number of ways Lulu can concatenate two non-overlapping, non-empty substrings from her string in order to get a repetitive string.

예제2

  1. 예제 1

    입력
    aaaa
    
    예상 출력
    9
    
  2. 예제 2

    입력
    axabxbcxcdxd
    
    예상 출력
    22