結果

問題 No.2204 Palindrome Splitting (No Rearrangement ver.)
ユーザー 鴨志田卓鴨志田卓
提出日時 2023-07-21 01:08:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 273 ms / 2,000 ms
コード長 522 bytes
コンパイル時間 2,229 ms
コンパイル使用メモリ 201,932 KB
実行使用メモリ 70,616 KB
最終ジャッジ日時 2023-10-21 03:01:42
合計ジャッジ時間 10,477 ms
ジャッジサーバーID
(参考情報)
judge15 / 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 153 ms
47,000 KB
testcase_04 AC 35 ms
17,380 KB
testcase_05 AC 21 ms
12,536 KB
testcase_06 AC 267 ms
70,616 KB
testcase_07 AC 236 ms
65,132 KB
testcase_08 AC 227 ms
60,672 KB
testcase_09 AC 229 ms
62,924 KB
testcase_10 AC 264 ms
70,616 KB
testcase_11 AC 213 ms
60,668 KB
testcase_12 AC 265 ms
70,144 KB
testcase_13 AC 263 ms
70,616 KB
testcase_14 AC 264 ms
70,616 KB
testcase_15 AC 242 ms
66,508 KB
testcase_16 AC 100 ms
34,448 KB
testcase_17 AC 134 ms
42,168 KB
testcase_18 AC 265 ms
70,616 KB
testcase_19 AC 261 ms
70,616 KB
testcase_20 AC 262 ms
70,616 KB
testcase_21 AC 261 ms
70,616 KB
testcase_22 AC 263 ms
70,616 KB
testcase_23 AC 261 ms
70,616 KB
testcase_24 AC 268 ms
70,616 KB
testcase_25 AC 262 ms
70,616 KB
testcase_26 AC 266 ms
70,616 KB
testcase_27 AC 171 ms
51,156 KB
testcase_28 AC 267 ms
70,616 KB
testcase_29 AC 273 ms
70,616 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 214 ms
57,356 KB
testcase_33 AC 267 ms
70,616 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 216 ms
57,352 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