結果

問題 No.2204 Palindrome Splitting (No Rearrangement ver.)
ユーザー 👑 kakel-sankakel-san
提出日時 2023-02-03 22:00:43
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 1,251 bytes
コンパイル時間 1,493 ms
コンパイル使用メモリ 68,184 KB
実行使用メモリ 48,740 KB
最終ジャッジ日時 2023-09-15 17:50:14
合計ジャッジ時間 6,119 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
22,656 KB
testcase_01 AC 50 ms
20,704 KB
testcase_02 AC 50 ms
20,672 KB
testcase_03 AC 77 ms
34,108 KB
testcase_04 AC 58 ms
21,132 KB
testcase_05 AC 55 ms
23,776 KB
testcase_06 AC 96 ms
46,336 KB
testcase_07 AC 92 ms
43,892 KB
testcase_08 AC 88 ms
43,944 KB
testcase_09 AC 90 ms
45,020 KB
testcase_10 AC 99 ms
48,404 KB
testcase_11 AC 88 ms
41,892 KB
testcase_12 AC 96 ms
46,060 KB
testcase_13 AC 96 ms
46,524 KB
testcase_14 AC 96 ms
48,372 KB
testcase_15 AC 94 ms
46,452 KB
testcase_16 AC 69 ms
31,324 KB
testcase_17 AC 75 ms
30,188 KB
testcase_18 AC 99 ms
48,332 KB
testcase_19 AC 98 ms
48,356 KB
testcase_20 AC 98 ms
48,408 KB
testcase_21 AC 98 ms
48,740 KB
testcase_22 AC 97 ms
44,460 KB
testcase_23 AC 97 ms
46,684 KB
testcase_24 AC 99 ms
48,344 KB
testcase_25 AC 99 ms
46,384 KB
testcase_26 AC 98 ms
48,388 KB
testcase_27 AC 82 ms
33,744 KB
testcase_28 AC 99 ms
46,320 KB
testcase_29 AC 96 ms
46,428 KB
testcase_30 AC 50 ms
20,580 KB
testcase_31 AC 51 ms
22,640 KB
testcase_32 AC 187 ms
42,684 KB
testcase_33 AC 97 ms
46,480 KB
testcase_34 AC 51 ms
20,680 KB
testcase_35 AC 187 ms
42,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var s = ReadLine();

        var pal = new bool[s.Length, s.Length + 1];
        for (var i = 0; i < s.Length; ++i)
        {
            var d = 0;
            while (i - d >= 0 && i + d < s.Length && s[i - d] == s[i + d])
            {
                pal[i - d, i + d + 1] = true;
                ++d;
            }
        }
        for (var i = 0; i + 1 < s.Length; ++i)
        {
            var d = 0;
            while (i - d >= 0 && i + d + 1 < s.Length && s[i - d] == s[i + d + 1])
            {
                pal[i - d, i + d + 2] = true;
                ++d;
            }
        }
        var dp = new int[s.Length + 1];
        for (var i = 1; i <= s.Length; ++i) if (pal[0, i]) dp[i] = i;
        for (var i = 0; i < s.Length; ++i) for (var j = i + 1; j < dp.Length; ++j)
        {
            if (pal[i, j]) dp[j] = Math.Max(dp[j], Math.Min(dp[i], j - i));
        }
        WriteLine(dp[s.Length]);
    }
}
0