#6996. [ICPC 2022 Seoul R] Palindrome Type

    ID: 6996 传统题 1000ms 2048MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>P14730搜索2022深度优先搜索 DFSICPC双指针 two-pointer首尔

[ICPC 2022 Seoul R] Palindrome Type

[ICPC 2022 Seoul R] Palindrome Type

题目描述

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

Given a string ww, write a program to determine if ww is a type-kk palindrome where k=0,1,2,3k = 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 \leq n \leq 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$.
aababaa
0
abccbbab
2
acmicpc
-1

提示

(暂无提示) 标签: P14730|搜索|2022|深度优先搜索 DFS|ICPC|双指针 two-pointer|首尔

来源

P14730|[ICPC 2022 Seoul R] Palindrome Type