Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
123620 | 吴诗涵 | 最长回文子串 | C++ | Accepted | 3 MS | 284 KB | 748 | 2025-07-06 19:37:01 |
#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() using namespace std; int main(){ string str; int maxLen=1; cin>>str; for(int i=0;i<str.size();i++){ int temp=0; for(int j=str.size()-1;j>i;j--){ if(i+temp<j&&str[i+temp]==str[j]){ temp++; } else{ temp=0; continue; } if((i+temp)==(j-1)&&(2*temp+1)>maxLen) maxLen=(2*temp+1); else if((i+temp)==j&&(2*temp)>maxLen) maxLen=(2*temp); } } cout<<maxLen<<endl; return 0; }