Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
3615 | 邓小龙 | 最长回文子串 | C++ | Accepted | 941 MS | 276 KB | 571 | 2024-06-21 23:15:43 |
# include<iostream> # include<algorithm> # include<string> using namespace std; string s; bool fun(string ss){ string temp_ss=ss; reverse(temp_ss.begin(),temp_ss.end()); if(ss==temp_ss) return true; else return false; } int main(){ int max_n=1; getline(cin,s); int lens=s.size(); for(int i=0;i<lens-1;i++){ for(int j=lens;j>0;j--){ string temp=s.substr(i,j); if(fun(temp)&&temp.size()>max_n) max_n=temp.size(); } } cout<<max_n<<endl; return 0; }