#C9358. Detecting Palindromic Subsequence

    ID: 53442 Type: Default 1000ms 256MiB

Detecting Palindromic Subsequence

Detecting Palindromic Subsequence

Given a string s, determine whether there exists a contiguous palindromic substring of length at least 3. A palindrome is a string that reads the same backward as forward. For example, if s = abdbca, the substring bdb is a palindrome, so the expected output is Has Palindrome. Otherwise, the output should be No Palindrome.

The problem can be formulated mathematically as: find indices \( i \) and \( j \) with \( j-i+1 \ge 3 \) such that \[ s[i \dots j] = s[j \dots i]\ \] where \( s[i \dots j] \) denotes a contiguous substring of s.

Constraints: The string length is between 0 and 1000 characters.

inputFormat

A single line containing the string s.

outputFormat

Print Has Palindrome if there exists a contiguous palindromic substring of length at least 3; otherwise, print No Palindrome.## sample

abdbca
Has Palindrome