```
bool dp[1000][1000];
class Solution {
public:
string longestPalindrome(string s) {
int start=0;
int maxlen=1;
int len=s.length();
if(len==0)
return s;
//bool dp[len][len];
//memset(dp,false,sizeof(dp)/sizeof(bool));
for(int i=0;i<len;i++){
dp[i][i]=true;
if(i+1<len&&s[i]==s[i+1]){
dp[i][i+1]=true;
start=i;
maxlen=2;
}
}
for(int pos=2;pos<len;pos++){
for(int i=0;i<len-pos;i++){
if(s[i]==s[i+pos]&&dp[i+1][i+pos-1]){
dp[i][i+pos]=true;
maxlen=pos+1;
start=i;
}
}
}
return s.substr(start,maxlen);
}
};
```

The input is "aaabaaaa". I test it in the "Custom TestCase" and the answer is right. But the result is WA. The answer in the "Submission Result" is wrong. I don't know why. ==.