結果

問題 No.273 回文分解
ユーザー 明智重蔵明智重蔵
提出日時 2015-09-05 07:18:41
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 1,577 bytes
コンパイル時間 2,446 ms
コンパイル使用メモリ 105,632 KB
実行使用メモリ 23,632 KB
最終ジャッジ日時 2023-09-07 19:43:16
合計ジャッジ時間 6,167 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
23,576 KB
testcase_01 AC 62 ms
21,488 KB
testcase_02 AC 61 ms
21,440 KB
testcase_03 AC 60 ms
23,512 KB
testcase_04 AC 59 ms
21,592 KB
testcase_05 AC 62 ms
21,444 KB
testcase_06 AC 61 ms
21,560 KB
testcase_07 AC 63 ms
21,444 KB
testcase_08 AC 64 ms
19,436 KB
testcase_09 AC 62 ms
23,528 KB
testcase_10 AC 60 ms
21,532 KB
testcase_11 AC 62 ms
21,508 KB
testcase_12 AC 61 ms
21,560 KB
testcase_13 AC 62 ms
19,460 KB
testcase_14 AC 64 ms
21,536 KB
testcase_15 AC 61 ms
19,460 KB
testcase_16 AC 61 ms
21,488 KB
testcase_17 AC 66 ms
21,540 KB
testcase_18 AC 63 ms
19,636 KB
testcase_19 AC 61 ms
21,452 KB
testcase_20 AC 59 ms
21,564 KB
testcase_21 AC 60 ms
21,476 KB
testcase_22 AC 62 ms
23,632 KB
testcase_23 AC 62 ms
21,508 KB
testcase_24 AC 64 ms
19,580 KB
testcase_25 AC 61 ms
23,548 KB
testcase_26 AC 63 ms
23,548 KB
testcase_27 AC 62 ms
21,612 KB
testcase_28 AC 60 ms
21,492 KB
testcase_29 AC 62 ms
23,624 KB
testcase_30 AC 61 ms
21,488 KB
testcase_31 AC 59 ms
21,524 KB
testcase_32 AC 61 ms
21,544 KB
testcase_33 AC 62 ms
23,544 KB
testcase_34 AC 61 ms
21,520 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "Input4";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("ABACDDCEFGFE");
            //5
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("ZZ");
            //1
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("AABAAABBABBABBBAAABAA");
            //8
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string S = InputList[0];

        //回文判定
        Predicate<string> IsKaibun = (pStr) =>
            pStr.SequenceEqual(pStr.Reverse());

        //最長の回文以外は、1文字の回文とみなして
        //ナイーブに最長の回文を探す
        var KaibunList = new List<string>();
        for (int I = 0; I <= S.Length - 1; I++) {
            for (int J = S.Length - 1; I <= J; J--) {
                string wkStr = S.Substring(I, J - I + 1);
                if (IsKaibun(wkStr) == false) continue;
                KaibunList.Add(wkStr);
                break;
            }
        }

        //分解してない回文をRemove
        KaibunList.RemoveAll(X => X == S);

        Console.WriteLine(KaibunList.Max(X => X.Length));
    }
}
0