Run ID:135588

提交时间:2025-11-07 18:02:40

#include <bits/stdc++.h> using namespace std; bool hasPalindrome(const string &s) { int n = s.size(); // 奇数长度回文(中心为单个字符) for (int center = 0; center < n; ++center) { int l = center, r = center; while (l >= 0 && r < n && s[l] == s[r]) { if (r - l + 1 >= 2) return true; --l; ++r; } } // 偶数长度回文(中心为两个相邻字符) for (int center = 0; center < n - 1; ++center) { int l = center, r = center + 1; while (l >= 0 && r < n && s[l] == s[r]) { if (r - l + 1 >= 2) return true; --l; ++r; } } return false; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string s; if (cin >> s) { cout << (hasPalindrome(s) ? "Yes" : "No") << '\n'; } return 0; }