| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 152974 | 翁思宸 | 最长回文子串 | C++ | Accepted | 3 MS | 284 KB | 646 | 2026-05-08 18:46:51 |
//1473 最长回文子串 #include<iostream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; int main(){ string x; int m=1,t; cin>>x; for(int i=0;i<x.size();i++){ t=0; for(int j=x.size()-1;j>i;j--){ if((i+t)<j && x[i+t]==x[j]){ t++; } else { t=0; continue; } if((i+t)==(j-1) && (2*t+1)>m){ m=2*t+1; } else if((i+t)==j && (2*t)>m){ m=2*t; } } } cout<<m; return 0; }