Logo
(追記) (追記ここまで)

12800번 - Palinilap 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB36121034.483%

문제

A palindrome is a word that reads the same backwards as forwards. For example, “a”, “abba” and “anavolimilovana” are palindromes A sample is a string of one or more lower case letters of the English alphabet, and the weight of a sample is the number of its substrings (words) that are palindromes, counting each word occurrence separately.

More precisely, let w be a sample of length n. The word wa,b is obtained by taking all characters from position a to position b in sample w. The weight of sample w is defined as the number of different pairs of integers a, b (1 ≤ abn) such that the word wa,b is a palindrome.

You are given the sample w. It can either be left unchanged, or exactly one position can be chosen and the letter on that position arbitrarily changed. Find the maximal possible sample weight that can be obtained as described above.

입력

The first line of input contains the given sample w – a string of lower case letters of the English alphabet.

출력

You must output the required maximal possible weight.

제한

서브태스크

번호배점제한
117

1 ≤ n ≤ 100

237

101 ≤ n ≤ 5 000

346

5001 ≤ n ≤ 100 000

예제 입력 1

aaaa

예제 출력 1

10

예제 입력 2

baccb

예제 출력 2

9

예제 입력 3

slavko

예제 출력 3

7

힌트

Clarification of the first example: Each substring from the sample already is a palindrome, so it is best left unchanged.

Clarification of the second example: If we change the second letter of the sample to “c”, we will get the sample “bcccb” with a weight of 9.

출처

Olympiad > Croatian Highschool Competitions in Informatics > 2016 > Croatian Olympiad in Informatics 2016 2번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /