結果
| 問題 | No.588 空白と回文 | 
| コンテスト | |
| ユーザー |  beet | 
| 提出日時 | 2018-07-27 15:27:48 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 13 ms / 2,000 ms | 
| コード長 | 629 bytes | 
| コンパイル時間 | 1,693 ms | 
| コンパイル使用メモリ | 167,168 KB | 
| 実行使用メモリ | 13,252 KB | 
| 最終ジャッジ日時 | 2024-07-01 03:31:25 | 
| 合計ジャッジ時間 | 2,813 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 25 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//INSERT ABOVE HERE
Int dp[1111][1111];
string s;
Int n;
// [l, r]
Int dfs(Int l,Int r){
  Int &res=dp[l][r];
  if(~res) return res;
  res=(s[l]==s[r])*(1+(l!=r));
  if(l+1<=r-1) res+=dfs(l+1,r-1);
  return res;
}
signed main(){
  cin>>s;
  n=s.size();
  Int ans=0;
  memset(dp,-1,sizeof(dp));
  for(Int i=0;i<n;i++)
    for(Int j=i;j<n;j++)
      chmax(ans,dfs(i,j));
  cout<<ans<<endl;
  return 0;
}
            
            
            
        