Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
115525 彭士宝 31回文字符串II C++ Compile Error 0 MS 0 KB 898 2025-03-31 15:32:37

Tests(0/0):


Code:

def has_palindrome_substring(s: str) -> bool: n = len(s) # 中心扩展法 def expand_around_center(left: int, right: int) -> bool: while left >= 0 and right < n and s[left] == s[right]: if right - left + 1 >= 2: # 如果长度大于等于2 return True left -= 1 right += 1 return False for i in range(n): # 检查奇数长度的回文子串(以单个字符为中心) if expand_around_center(i, i): return True # 检查偶数长度的回文子串(以两个字符为中心) if expand_around_center(i, i + 1): return True return False # 主程序 if __name__ == "__main__": s = input().strip() # 输入字符串 if has_palindrome_substring(s): print("Yes") else: print("No")