結果

問題 No.2204 Palindrome Splitting (No Rearrangement ver.)
ユーザー tamatotamato
提出日時 2023-02-03 21:39:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 893 ms / 2,000 ms
コード長 1,198 bytes
コンパイル時間 963 ms
コンパイル使用メモリ 87,300 KB
実行使用メモリ 274,356 KB
最終ジャッジ日時 2023-09-15 17:18:14
合計ジャッジ時間 10,911 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,240 KB
testcase_01 AC 74 ms
71,460 KB
testcase_02 AC 76 ms
71,456 KB
testcase_03 AC 207 ms
183,644 KB
testcase_04 AC 109 ms
92,092 KB
testcase_05 AC 101 ms
91,176 KB
testcase_06 AC 274 ms
273,944 KB
testcase_07 AC 252 ms
252,116 KB
testcase_08 AC 236 ms
229,356 KB
testcase_09 AC 255 ms
243,892 KB
testcase_10 AC 282 ms
273,976 KB
testcase_11 AC 238 ms
229,496 KB
testcase_12 AC 282 ms
271,992 KB
testcase_13 AC 274 ms
274,044 KB
testcase_14 AC 279 ms
274,356 KB
testcase_15 AC 260 ms
252,676 KB
testcase_16 AC 151 ms
137,392 KB
testcase_17 AC 185 ms
175,376 KB
testcase_18 AC 280 ms
274,008 KB
testcase_19 AC 280 ms
273,940 KB
testcase_20 AC 278 ms
274,028 KB
testcase_21 AC 273 ms
273,788 KB
testcase_22 AC 270 ms
273,844 KB
testcase_23 AC 273 ms
274,164 KB
testcase_24 AC 282 ms
273,612 KB
testcase_25 AC 294 ms
274,096 KB
testcase_26 AC 299 ms
274,060 KB
testcase_27 AC 256 ms
203,652 KB
testcase_28 AC 276 ms
274,128 KB
testcase_29 AC 272 ms
273,964 KB
testcase_30 AC 72 ms
71,236 KB
testcase_31 AC 72 ms
71,324 KB
testcase_32 AC 511 ms
224,140 KB
testcase_33 AC 274 ms
273,860 KB
testcase_34 AC 70 ms
71,212 KB
testcase_35 AC 893 ms
223,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def main():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')
    N = len(S)

    G = [[0] * (N+1) for _ in range(N+1)]
    # odd
    for m in range(N):
        G[m][m+1] = 1
        for j in range(1, N + 1):
            if m - j < 0 or m + j >= N:
                break
            if S[m - j] == S[m + j]:
                G[m - j][m + j + 1] = 1
            else:
                break

    # even
    for m in range(1, N):
        for j in range(1, N+1):
            if m - j < 0 or m + j - 1 >= N:
                break
            if S[m - j] == S[m + j - 1]:
                G[m - j][m + j] = 1
            else:
                break

    ok = 1
    ng = N + 1
    mid = (ok + ng) // 2
    while ng - ok > 1:
        dp = [0] * (N+1)
        dp[0] = 1
        for i in range(N):
            if dp[i] == 0:
                continue
            for j in range(mid, N+1):
                if i + j >= N+1:
                    break
                if G[i][i+j]:
                    dp[i+j] = 1
        if dp[N]:
            ok = mid
        else:
            ng = mid
        mid = (ok + ng) // 2
    print(ok)


if __name__ == '__main__':
    main()
0