結果

問題 No.2204 Palindrome Splitting (No Rearrangement ver.)
ユーザー i_am_noobi_am_noob
提出日時 2023-02-12 03:05:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 630 bytes
コンパイル時間 2,295 ms
コンパイル使用メモリ 198,388 KB
実行使用メモリ 27,432 KB
最終ジャッジ日時 2023-09-22 21:33:45
合計ジャッジ時間 4,813 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 14 ms
23,416 KB
testcase_04 AC 6 ms
13,168 KB
testcase_05 AC 4 ms
11,212 KB
testcase_06 AC 22 ms
26,996 KB
testcase_07 AC 19 ms
25,940 KB
testcase_08 AC 18 ms
25,540 KB
testcase_09 AC 19 ms
25,440 KB
testcase_10 AC 21 ms
27,040 KB
testcase_11 AC 18 ms
25,424 KB
testcase_12 AC 22 ms
26,944 KB
testcase_13 AC 21 ms
27,120 KB
testcase_14 AC 21 ms
27,076 KB
testcase_15 AC 19 ms
26,300 KB
testcase_16 AC 10 ms
19,272 KB
testcase_17 AC 12 ms
21,328 KB
testcase_18 AC 21 ms
27,104 KB
testcase_19 AC 22 ms
27,032 KB
testcase_20 AC 21 ms
27,188 KB
testcase_21 AC 21 ms
27,380 KB
testcase_22 AC 22 ms
27,108 KB
testcase_23 AC 22 ms
27,432 KB
testcase_24 AC 21 ms
27,044 KB
testcase_25 AC 21 ms
27,192 KB
testcase_26 AC 21 ms
27,008 KB
testcase_27 AC 14 ms
23,576 KB
testcase_28 AC 21 ms
27,060 KB
testcase_29 AC 21 ms
27,392 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 67 ms
25,712 KB
testcase_33 AC 21 ms
27,352 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 66 ms
25,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;

#define all(a) a.begin(),a.end()
#define pb push_back
#define sz(a) ((int)a.size())

const int maxn=5005;
int n,dp[maxn];
string s;
bool a[maxn][maxn];

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> s; n=s.size();
    for(int i=0; i<=2*n-2; ++i){
        int l=i/2,r=i-l;
        while(l>=0&&r<n&&s[l]==s[r]) a[r][l]=1,l--,r++;
    }
    dp[0]=n+1;
    for(int i=0; i<n; ++i){
        dp[i+1]=-1;
        for(int j=0; j<=i; ++j) if(a[i][j]) dp[i+1]=max(dp[i+1],min(dp[j],i-j+1));
    }
    cout << dp[n] << "\n";
}
0