結果

問題 No.2204 Palindrome Splitting (No Rearrangement ver.)
ユーザー t98slidert98slider
提出日時 2023-02-03 21:46:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 723 bytes
コンパイル時間 1,766 ms
コンパイル使用メモリ 171,728 KB
実行使用メモリ 6,712 KB
最終ジャッジ日時 2023-09-15 17:27:38
合計ジャッジ時間 4,401 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 20 ms
5,188 KB
testcase_04 AC 6 ms
4,380 KB
testcase_05 AC 5 ms
4,380 KB
testcase_06 AC 35 ms
6,504 KB
testcase_07 AC 32 ms
6,252 KB
testcase_08 AC 30 ms
5,704 KB
testcase_09 AC 74 ms
5,896 KB
testcase_10 AC 51 ms
6,608 KB
testcase_11 AC 29 ms
5,592 KB
testcase_12 AC 37 ms
6,484 KB
testcase_13 AC 34 ms
6,712 KB
testcase_14 AC 48 ms
6,504 KB
testcase_15 AC 59 ms
6,252 KB
testcase_16 AC 13 ms
4,388 KB
testcase_17 AC 23 ms
4,800 KB
testcase_18 AC 36 ms
6,504 KB
testcase_19 AC 58 ms
6,504 KB
testcase_20 AC 43 ms
6,412 KB
testcase_21 AC 34 ms
6,548 KB
testcase_22 AC 38 ms
6,396 KB
testcase_23 AC 44 ms
6,576 KB
testcase_24 AC 87 ms
6,528 KB
testcase_25 AC 57 ms
6,568 KB
testcase_26 AC 34 ms
6,412 KB
testcase_27 AC 55 ms
5,132 KB
testcase_28 AC 52 ms
6,612 KB
testcase_29 AC 34 ms
6,532 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 46 ms
5,604 KB
testcase_33 AC 41 ms
6,532 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 46 ms
5,660 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