#C5057. Palindromic Subsequence Marking
Palindromic Subsequence Marking
Palindromic Subsequence Marking
Given a string s consisting of lowercase English letters, determine whether there exists a contiguous substring of s (with a length of at least 2) that forms a palindrome. A palindrome is a string that reads the same backward as forward. Formally, you need to check if there exist indices \( i \) and \( j \) with \( 0 \le i < j < |s| \) such that the substring \( s[i \ldots j] \) satisfies \( s[i \ldots j] = \text{reverse}(s[i \ldots j]) \).
If such a substring exists, output YES
; otherwise, output NO
.
Examples:
- For
s = "ababa"
, the substring "aba" (or even "ababa") is a palindrome, so the output isYES
. - For
s = "abcdef"
, no contiguous palindromic substring of length \( \ge 2 \) exists, so the output isNO
.
inputFormat
The input consists of a single line containing the string ( s ) where ( 1 \leq |s| \leq 10^5 ).
outputFormat
Output a single line: YES
if there exists a contiguous palindromic substring of length at least 2; otherwise, output NO
.## sample
ababa
YES