結果
問題 | No.273 回文分解 |
ユーザー |
![]() |
提出日時 | 2015-08-29 02:11:19 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 565 bytes |
コンパイル時間 | 1,427 ms |
コンパイル使用メモリ | 159,552 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-25 13:26:47 |
合計ジャッジ時間 | 2,507 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h>using namespace std;string s;int dp[51];bool chk(int st,int ed){ed--;while(st<ed){if(s[st]!=s[ed])return false;st++;ed--;}return true;}int rek(int st,bool a){if(dp[st]==-1){int r=1;for(int ctr1=st+1;ctr1<=s.length()-a;ctr1++){if(chk(st,ctr1)){r=max(ctr1-st,max(r,rek(ctr1,false)));}}dp[st]=r;}return dp[st];}int main(){memset(dp,-1,sizeof(dp));cin>>s;cout<<rek(0,true);return 0;}