Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
46101 张俊杰 最长回文子串 C++ Accepted 4 MS 280 KB 931 2023-04-14 21:19:54

Tests(15/15):


Code:

#include <iostream> #include <string> using namespace std; int main() { string a; while(getline(cin,a)) { int max=0; int s=a.size(); for(int i=0;i<s;++i) { for(int j=a.size()-1;j>i;--j) { int m=i,n=j,t=0; while(a[m]==a[n]) { t++; m++; n--; if(m>=n) { if(m==n){ t=2*t+1; } else{ t=2*t; } if(t>max){ max=t; } break; } } } } cout<<max<<endl; } return 0; }