結果

問題 No.1617 Palindrome Removal
ユーザー 👑 kakel-sankakel-san
提出日時 2021-07-22 21:33:27
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 926 bytes
コンパイル時間 2,536 ms
コンパイル使用メモリ 71,876 KB
実行使用メモリ 25,944 KB
最終ジャッジ日時 2023-09-24 15:55:46
合計ジャッジ時間 3,699 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
23,696 KB
testcase_01 AC 66 ms
23,828 KB
testcase_02 AC 63 ms
23,760 KB
testcase_03 AC 63 ms
25,684 KB
testcase_04 AC 64 ms
23,888 KB
testcase_05 AC 60 ms
23,080 KB
testcase_06 AC 61 ms
23,828 KB
testcase_07 AC 60 ms
22,332 KB
testcase_08 AC 52 ms
22,568 KB
testcase_09 AC 51 ms
20,464 KB
testcase_10 AC 63 ms
25,696 KB
testcase_11 AC 61 ms
25,220 KB
testcase_12 AC 62 ms
23,968 KB
testcase_13 AC 64 ms
25,944 KB
testcase_14 AC 52 ms
18,496 KB
testcase_15 AC 52 ms
22,596 KB
testcase_16 AC 52 ms
20,552 KB
testcase_17 AC 53 ms
20,588 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 52 ms
18,588 KB
testcase_21 AC 51 ms
20,464 KB
testcase_22 AC 53 ms
18,432 KB
testcase_23 AC 52 ms
20,576 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();
        if (!IsPalindrome(s))
        {
            WriteLine(s.Length);
        }
        else if (!IsOneChars(s))
        {
            WriteLine(s.Length - 2);
        }
        else
        {
            WriteLine(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