結果

問題 No.2204 Palindrome Splitting (No Rearrangement ver.)
ユーザー 鴨志田卓鴨志田卓
提出日時 2023-07-20 20:35:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 522 bytes
コンパイル時間 1,826 ms
コンパイル使用メモリ 201,844 KB
実行使用メモリ 70,632 KB
最終ジャッジ日時 2023-10-20 21:27:26
合計ジャッジ時間 10,011 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 139 ms
47,016 KB
testcase_04 AC 34 ms
17,396 KB
testcase_05 AC 17 ms
12,552 KB
testcase_06 AC 247 ms
70,632 KB
testcase_07 AC 219 ms
65,148 KB
testcase_08 AC 198 ms
60,688 KB
testcase_09 AC 207 ms
62,940 KB
testcase_10 AC 255 ms
70,632 KB
testcase_11 AC 195 ms
60,684 KB
testcase_12 AC 249 ms
70,160 KB
testcase_13 AC 253 ms
70,632 KB
testcase_14 AC 243 ms
70,632 KB
testcase_15 AC 225 ms
66,524 KB
testcase_16 AC 89 ms
34,464 KB
testcase_17 AC 120 ms
42,184 KB
testcase_18 AC 246 ms
70,632 KB
testcase_19 AC 254 ms
70,632 KB
testcase_20 AC 244 ms
70,632 KB
testcase_21 AC 248 ms
70,632 KB
testcase_22 AC 249 ms
70,632 KB
testcase_23 AC 248 ms
70,632 KB
testcase_24 AC 250 ms
70,632 KB
testcase_25 AC 257 ms
70,632 KB
testcase_26 AC 253 ms
70,632 KB
testcase_27 AC 159 ms
51,172 KB
testcase_28 AC 245 ms
70,632 KB
testcase_29 AC 251 ms
70,632 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 203 ms
57,372 KB
testcase_33 AC 244 ms
70,632 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 193 ms
57,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const int N = 5050;

char s[N];
int n;

int ok[N][N], dp[N];

bool p(int l, int r) {
    if(r - l < 1) return true;
    if(!ok[l][r])
        ok[l][r] = p(l + 1, r - 1) && s[l] == s[r] ? 1 : -1;
    return ok[l][r] > 0;
}

int main() {
    cin >> (s + 1);
    n = strlen(s + 1);
    dp[0] = N;
    for(int i = 1; i <= n; i ++) {
        for(int j = 1; j <= i; j ++) {
            if(p(j, i)) dp[i] = max(dp[i], min(dp[j - 1], i - j + 1));
        }
    }
    cout << dp[n];
}
0