Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
135588 李明秦 31回文字符串II C++ Wrong Answer 1 MS 292 KB 904 2025-11-07 18:02:40

Tests(5/10):


Code:

#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; }


Run Info:

------Input------
aa
------Answer-----
No
------Your output-----
Yes