Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
3594 | 吴奕希 | 最长回文子串 | C++ | Accepted | 139 MS | 276 KB | 484 | 2024-06-15 17:09:49 |
# include<iostream> # include<cstring> using namespace std; int is_pd(string s1){ int n = s1.size(); for(int i = 0; i < n/2+n%2; i++)if(s1[i]!=s1[n-1-i])return 0; return n; } int main(){ string a; int _max = 1; cin>>a; int s = a.size(); for(int i = 0; i < s-1; i++){ for(int j = i+1; j < s; j++){ int c = is_pd(a.substr(i, j-i+1)); if(c>_max)_max = c; } } cout<<_max; return 0; }