Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
58010 王嘉瑜 最长回文子串 C++ Accepted 200 MS 280 KB 464 2023-09-16 21:39:44

Tests(15/15):


Code:

#include <iostream> #include <string> using namespace std; bool huiwen(string a){ for(int i=0;i<a.size();i++){ if(a[i]!=a[a.size()-i-1]){ return false; } } return true; } int main(){ string s; cin>>s; int ans = 0; for(int len=s.size();len>0;len--){ for(int start=0;start+len<=s.size();start++){ string sub = s.substr(start,len); if(huiwen(sub)){ cout<<len; return 0; } } } return 0; }