Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
115163 | 夏梓瑞 | 最长回文子串 | C++ | Accepted | 4 MS | 280 KB | 780 | 2025-03-29 15:55:58 |
#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min()\fabs() #include<ctime> #include<cstdlib> #include<cstring> using namespace std; int main(){ string str; int a=1; cin>>str; for(int i=0;i<str.size();i++){ int b=0; for(int j=str.size()-1;j>i;j--){ if((i+b<j)&&(str[i+b]==str[j])) b++; else{ b=0; continue; } if((i+b)==(j-1)&&(2*b+1)>a) a=(2*b+1); else if((i+b)==j&&(2*b)>a) a=(2*b); } } cout<<a<<endl; return 0; }