結果

問題 No.273 回文分解
ユーザー bluemeganebluemegane
提出日時 2020-09-11 15:11:57
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,158 bytes
コンパイル時間 1,528 ms
コンパイル使用メモリ 63,076 KB
実行使用メモリ 24,656 KB
最終ジャッジ日時 2023-08-26 22:04:38
合計ジャッジ時間 5,290 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
22,572 KB
testcase_01 AC 54 ms
24,580 KB
testcase_02 AC 53 ms
20,656 KB
testcase_03 AC 53 ms
20,472 KB
testcase_04 AC 54 ms
22,524 KB
testcase_05 AC 53 ms
20,480 KB
testcase_06 AC 53 ms
20,520 KB
testcase_07 AC 53 ms
20,496 KB
testcase_08 AC 52 ms
20,476 KB
testcase_09 AC 52 ms
20,484 KB
testcase_10 AC 53 ms
18,532 KB
testcase_11 AC 52 ms
20,556 KB
testcase_12 AC 53 ms
22,620 KB
testcase_13 AC 52 ms
22,560 KB
testcase_14 AC 52 ms
22,532 KB
testcase_15 AC 53 ms
20,664 KB
testcase_16 AC 54 ms
20,460 KB
testcase_17 AC 53 ms
20,556 KB
testcase_18 WA -
testcase_19 AC 53 ms
20,472 KB
testcase_20 AC 52 ms
20,464 KB
testcase_21 AC 52 ms
20,556 KB
testcase_22 AC 53 ms
22,532 KB
testcase_23 WA -
testcase_24 AC 54 ms
22,464 KB
testcase_25 AC 53 ms
20,476 KB
testcase_26 AC 53 ms
22,512 KB
testcase_27 AC 53 ms
20,612 KB
testcase_28 AC 53 ms
20,504 KB
testcase_29 AC 53 ms
20,552 KB
testcase_30 AC 53 ms
20,552 KB
testcase_31 WA -
testcase_32 AC 52 ms
22,468 KB
testcase_33 AC 53 ms
20,420 KB
testcase_34 AC 52 ms
20,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using static System.Math;
using System;

public class Hello
{
    static void Main()
    {
        var s = Console.ReadLine().Trim();
        getAns(s);

    }
    static int check2(string s, int p)
    {
        var sL = s.Length;
        var d = 0;
        var count = 0;
        while (true)
        {
            if (p + d + 1 == sL | p - d < 0) break;
            if (s[p - d] == s[p + d + 1]) count += 2;
            else break;
            d++;
        }
        return count;
    }
    static int check1(string s, int p)
    {
        var sL = s.Length;
        var d = 1;
        var count = 1;
        while (true)
        {
            if (p + d == sL | p - d < 0) break;
            if (s[p + d] == s[p - d]) count += 2;
            else break;
            d++;
        }
        return count;
    }
    static void getAns(string s)
    {
        var sL = s.Length;
        var ans = 1;
        for (int i = 0; i < sL; i++)
        {
            var t0 = check1(s, i);
            var t1 = check2(s, i);
            if (t0 != sL) ans = Max(ans, t0);
            if (t1 != sL) ans = Max(ans, t1);
        }
        Console.WriteLine(ans);
    }
}
0