結果

問題 No.1617 Palindrome Removal
ユーザー 👑 kakel-sankakel-san
提出日時 2021-07-22 21:47:12
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 997 bytes
コンパイル時間 1,826 ms
コンパイル使用メモリ 63,720 KB
実行使用メモリ 17,756 KB
最終ジャッジ日時 2023-09-24 16:24:38
合計ジャッジ時間 4,693 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
17,532 KB
testcase_01 AC 64 ms
17,736 KB
testcase_02 AC 61 ms
17,504 KB
testcase_03 AC 64 ms
17,504 KB
testcase_04 AC 61 ms
17,756 KB
testcase_05 AC 58 ms
16,972 KB
testcase_06 AC 59 ms
17,736 KB
testcase_07 AC 56 ms
16,228 KB
testcase_08 AC 49 ms
14,352 KB
testcase_09 AC 49 ms
14,356 KB
testcase_10 AC 60 ms
17,588 KB
testcase_11 AC 59 ms
16,980 KB
testcase_12 AC 61 ms
17,720 KB
testcase_13 AC 61 ms
17,744 KB
testcase_14 AC 50 ms
14,372 KB
testcase_15 AC 49 ms
14,352 KB
testcase_16 AC 49 ms
14,332 KB
testcase_17 AC 51 ms
14,452 KB
testcase_18 AC 51 ms
14,420 KB
testcase_19 AC 51 ms
14,356 KB
testcase_20 AC 49 ms
14,432 KB
testcase_21 AC 50 ms
14,388 KB
testcase_22 AC 51 ms
14,356 KB
testcase_23 AC 50 ms
14,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;

class yuki1
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static void Main()
    {
        var s = ReadLine();
        WriteLine(Pa(s));
    }
    static int Pa(string s)
    {
        if (!IsPalindrome(s))
        {
            return s.Length;
        }
        else if (!IsOneChars(s) && s.Length != 3)
        {
            return s.Length - 2;
        }
        else
        {
            return 0 - (s.Length % 2);
        }
    }
    static bool IsOneChars(string s)
    {
        for (var i = 0; i < s.Length - 1; ++i)
        {
            if (s[i] != s[i + 1]) return false;
        }
        return true;
    }
    static bool IsPalindrome(string s)
    {
        for (var i = 0; i < s.Length / 2; ++i)
        {
            if (s[i] != s[s.Length - i - 1]) return false;
        }
        return true;
    }
}
0