logo AlgoBeat OnlineJudge
登录 注册

#214835. [ICPC 2022 Seoul R] Palindrome Type

内存限制:2048 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

A palindrome string is a word which reads the same backward as forward, such as or . 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 , if is the minimum number of characters removed to make the string a palindrome, we call the string a type- palindrome. Thus, if is a palindrome, then is a type-0 palindrome.

Given a string , write a program to determine if is a type- palindrome where .

输入格式

Your program is to read from standard input. The input is a single line containing a string with length () of lowercase alphabets.

输出格式

Your program is to write to standard output. Print exactly one line. The line should contain a number among if the input string is a type- palindrome where and otherwise . The negative number means the input string is not a type- palindrome where .

样例

样例输入 1

aababaa

样例输出 1

0

样例输入 2

abccbbab

样例输出 2

2

样例输入 3

acmicpc

样例输出 3

-1