結果

問題 No.2204 Palindrome Splitting (No Rearrangement ver.)
ユーザー t98slidert98slider
提出日時 2023-02-03 21:46:07
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 723 bytes
コンパイル時間 1,412 ms
使用メモリ 6,676 KB
最終ジャッジ日時 2023-02-03 21:46:11
合計ジャッジ時間 4,147 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
4,904 KB
testcase_01 AC 1 ms
4,900 KB
testcase_02 AC 2 ms
4,900 KB
testcase_03 AC 21 ms
5,220 KB
testcase_04 AC 6 ms
5,156 KB
testcase_05 AC 5 ms
3,584 KB
testcase_06 AC 36 ms
6,636 KB
testcase_07 AC 33 ms
5,964 KB
testcase_08 AC 31 ms
5,756 KB
testcase_09 AC 76 ms
6,048 KB
testcase_10 AC 52 ms
6,512 KB
testcase_11 AC 28 ms
5,624 KB
testcase_12 AC 38 ms
6,644 KB
testcase_13 AC 36 ms
6,600 KB
testcase_14 AC 49 ms
6,576 KB
testcase_15 AC 60 ms
6,312 KB
testcase_16 AC 14 ms
4,904 KB
testcase_17 AC 23 ms
4,900 KB
testcase_18 AC 38 ms
6,668 KB
testcase_19 AC 57 ms
6,644 KB
testcase_20 AC 44 ms
6,524 KB
testcase_21 AC 36 ms
6,528 KB
testcase_22 AC 39 ms
6,652 KB
testcase_23 AC 43 ms
6,528 KB
testcase_24 AC 89 ms
6,648 KB
testcase_25 AC 57 ms
6,596 KB
testcase_26 AC 35 ms
6,524 KB
testcase_27 AC 57 ms
5,204 KB
testcase_28 AC 52 ms
6,516 KB
testcase_29 AC 35 ms
6,528 KB
testcase_30 AC 1 ms
5,156 KB
testcase_31 AC 2 ms
4,904 KB
testcase_32 AC 46 ms
5,748 KB
testcase_33 AC 41 ms
6,676 KB
testcase_34 AC 1 ms
5,164 KB
testcase_35 AC 46 ms
5,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    vector<vector<bool>> dp2(n + 1, vector<bool>(n + 1));
    for(int i = 0; i < n; i++)dp2[i][i] = dp2[i][i + 1] = true;
    for(int len = 2; len <= n; len++){
        for(int l = 0; l + len <= n; l++){
            if(s[l] == s[l + len - 1] && dp2[l + 1][l + len - 1])dp2[l][l + len] = true;
        }
    }
    vector<int> dp(n + 1, -1);
    dp[0] = 1 << 30;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j <= n; j++){
            if(dp2[i][j]) dp[j] = max(dp[j], min(dp[i], j - i));
        }
    }
    cout << dp[n] << '\n';
}
0