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

26110번 - Palindrome Type 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB67233727655.090%

문제

A palindrome string is a word which reads the same backward as forward, such as madam or racecar. In this problem we only consider strings with lowercase alphabets.

We newly define the types of palindromes. If a string is not a palindrome, we try to make it a palindrome by removing the minimum number of characters in the string. For a string $w,ドル if $k$ is the minimum number of characters removed to make the string a palindrome, we call the string $w$ type-$k$ palindrome. Thus, if $w$ is a palindrome, then $w$ is a type-0ドル$ palindrome.

Given a string $w,ドル write a program to determine if $w$ is a type-$k$ palindrome where $k = 0, 1, 2, 3$.

입력

Your program is to read from standard input. The input is a single line containing a string $w$ with length $n$ (5ドル ≤ n ≤ 10^5$) of lowercase alphabets.

출력

Your program is to write to standard output. Print exactly one line. The line should contain a number $k$ among $\{0, 1, 2, 3, -1\}$ if the input string is a type-$k$ palindrome where $k = 0, 1, 2, 3$ and otherwise $-1$. The negative number $-1$ means the input string is not a type-$k$ palindrome where $k = 0, 1, 2, 3$.

제한

예제 입력 1

aababaa

예제 출력 1

0

예제 입력 2

abccbbab

예제 출력 2

2

예제 입력 3

acmicpc

예제 출력 3

-1

힌트

출처

ICPC > Regionals > Asia Pacific > Korea > Asia Regional - Seoul 2022 I번

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

출처

대학교 대회

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

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