結果

問題 No.2204 Palindrome Splitting (No Rearrangement ver.)
ユーザー 鴨志田卓鴨志田卓
提出日時 2023-07-21 01:09:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 261 ms / 2,000 ms
コード長 522 bytes
コンパイル時間 2,165 ms
コンパイル使用メモリ 201,796 KB
実行使用メモリ 70,588 KB
最終ジャッジ日時 2023-10-21 03:02:06
合計ジャッジ時間 10,049 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 147 ms
46,972 KB
testcase_04 AC 34 ms
17,352 KB
testcase_05 AC 19 ms
12,508 KB
testcase_06 AC 256 ms
70,588 KB
testcase_07 AC 228 ms
65,104 KB
testcase_08 AC 210 ms
60,644 KB
testcase_09 AC 224 ms
62,896 KB
testcase_10 AC 254 ms
70,588 KB
testcase_11 AC 207 ms
60,640 KB
testcase_12 AC 259 ms
70,116 KB
testcase_13 AC 254 ms
70,588 KB
testcase_14 AC 253 ms
70,588 KB
testcase_15 AC 233 ms
66,480 KB
testcase_16 AC 100 ms
34,420 KB
testcase_17 AC 131 ms
42,140 KB
testcase_18 AC 258 ms
70,588 KB
testcase_19 AC 255 ms
70,588 KB
testcase_20 AC 256 ms
70,588 KB
testcase_21 AC 254 ms
70,588 KB
testcase_22 AC 255 ms
70,588 KB
testcase_23 AC 251 ms
70,588 KB
testcase_24 AC 256 ms
70,588 KB
testcase_25 AC 261 ms
70,588 KB
testcase_26 AC 252 ms
70,588 KB
testcase_27 AC 166 ms
51,128 KB
testcase_28 AC 260 ms
70,588 KB
testcase_29 AC 255 ms
70,588 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 209 ms
57,328 KB
testcase_33 AC 260 ms
70,588 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 208 ms
57,324 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