結果

問題 No.273 回文分解
ユーザー 14番14番
提出日時 2016-05-10 23:08:14
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,413 bytes
コンパイル時間 2,127 ms
コンパイル使用メモリ 108,864 KB
実行使用メモリ 22,760 KB
最終ジャッジ日時 2023-08-25 01:30:33
合計ジャッジ時間 4,980 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 49 ms
20,596 KB
testcase_02 AC 48 ms
22,728 KB
testcase_03 AC 48 ms
20,644 KB
testcase_04 WA -
testcase_05 AC 48 ms
20,536 KB
testcase_06 AC 47 ms
18,628 KB
testcase_07 AC 49 ms
20,556 KB
testcase_08 AC 47 ms
20,592 KB
testcase_09 AC 49 ms
22,760 KB
testcase_10 AC 48 ms
18,608 KB
testcase_11 AC 48 ms
20,664 KB
testcase_12 AC 47 ms
20,608 KB
testcase_13 AC 47 ms
20,596 KB
testcase_14 AC 47 ms
20,716 KB
testcase_15 AC 47 ms
22,576 KB
testcase_16 AC 46 ms
18,568 KB
testcase_17 AC 47 ms
20,740 KB
testcase_18 WA -
testcase_19 AC 49 ms
22,560 KB
testcase_20 AC 49 ms
22,708 KB
testcase_21 AC 48 ms
20,524 KB
testcase_22 AC 49 ms
20,648 KB
testcase_23 WA -
testcase_24 AC 48 ms
20,532 KB
testcase_25 AC 49 ms
18,596 KB
testcase_26 AC 50 ms
18,500 KB
testcase_27 AC 49 ms
20,652 KB
testcase_28 AC 48 ms
20,656 KB
testcase_29 AC 49 ms
20,632 KB
testcase_30 AC 50 ms
20,632 KB
testcase_31 WA -
testcase_32 AC 48 ms
20,544 KB
testcase_33 AC 49 ms
22,620 KB
testcase_34 AC 48 ms
20,664 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.Text;
using System.Linq;

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int ans = this.GetAns(Reader.ReadLine());
        Console.WriteLine(ans);

    }
    private int GetAns(string inpt) {
        int ans  = 1;
        
        for(int i=0; i<inpt.Length; i++) {
            // i を中央と考えた場合
            int len = 1;
            for(int j=0; i  - j >= 0 && i + j < inpt.Length; j++) {
                if(inpt[i-j] != inpt[i+j]) {
                    break;
                } else
                {
                    len = 1 + (j * 2);
                }
            }
            ans = Math.Max(ans, len);
            // i を偶数この文字列の左側とした場合
            len = 1;
            if(i < inpt.Length - 1 && inpt[i] == inpt[i+1]) {
                for(int j=0; i-j >= 0 && i+1+j < inpt.Length; j++) {
                    if(inpt[i-j] != inpt[i+1+j]) {
                        break;
                    } else
                    {
                        len = 2 + (j * 2);
                    }
                }
                ans = Math.Max(ans, len);
            }
        }
        return ans;
    }

    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"


AABAAABBABBABBBAAABAA




 
";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        public static int[] GetInt(char delimiter = ' ', bool trim = false)
        {
            string inptStr = ReadLine();
            if (trim)
            {
                inptStr = inptStr.Trim();
            }
            string[] inpt = inptStr.Split(delimiter);
            int[] ret = new int[inpt.Length];
            for (int i = 0; i < inpt.Length; i++)
            {
                ret[i] = int.Parse(inpt[i]);
            }
            return ret;
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0