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

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

Positive String

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

요약
문자열 S의 연속 부분 문자열 중 뒤집은 문자열보다 사전순으로 큰 것의 개수를 센다.
난이도

보통10점 중 6점

유형
문자열, 정렬, 구현
정답자
아직 제출이 없습니다

문제

Grammy had a unique insight about strings. She thinks that a string is positive if and only if it is lexicographically larger than its reversal.

Now you are given a string, please find out how many contiguous substrings of it are positive according to Grammy's insight.

입력

The single line contains a string SS (1≤∣S∣≤200,0001 \leq |S| \leq 200\\,000), consisting of lowercase English letters only.

출력

Output a single integer denoting the number of positive substrings of SS.

예제2

  1. 예제 1

    입력
    jjikkollp
    
    예상 출력
    4
    
  2. 예제 2

    입력
    pbpbppb
    
    예상 출력
    7