結果

問題 No.1617 Palindrome Removal
ユーザー さかぽんさかぽん
提出日時 2021-07-22 23:04:32
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 683 bytes
コンパイル時間 2,135 ms
コンパイル使用メモリ 107,576 KB
実行使用メモリ 26,816 KB
最終ジャッジ日時 2023-09-24 18:56:42
合計ジャッジ時間 5,234 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
26,796 KB
testcase_01 AC 96 ms
24,760 KB
testcase_02 AC 95 ms
24,596 KB
testcase_03 AC 94 ms
24,596 KB
testcase_04 AC 97 ms
24,712 KB
testcase_05 AC 89 ms
25,988 KB
testcase_06 AC 63 ms
24,588 KB
testcase_07 AC 58 ms
23,156 KB
testcase_08 AC 51 ms
21,360 KB
testcase_09 AC 52 ms
21,268 KB
testcase_10 AC 95 ms
24,584 KB
testcase_11 AC 92 ms
24,036 KB
testcase_12 AC 98 ms
26,816 KB
testcase_13 AC 97 ms
24,860 KB
testcase_14 AC 55 ms
23,396 KB
testcase_15 AC 52 ms
21,252 KB
testcase_16 AC 55 ms
21,468 KB
testcase_17 AC 56 ms
21,584 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 54 ms
21,500 KB
testcase_21 AC 54 ms
21,496 KB
testcase_22 AC 56 ms
21,444 KB
testcase_23 AC 55 ms
21,508 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 B
{
	static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
	static (int, int) Read2() { var a = Read(); return (a[0], a[1]); }
	static long[] ReadL() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	static void Main() => Console.WriteLine(Solve());
	static object Solve()
	{
		var s = Console.ReadLine();
		var n = s.Length;

		if (!IsPalindrome(s)) return n;
		if (s.Distinct().Count() > 1) return n - 2;
		return -n % 2;
	}

	static bool IsPalindrome(string s)
	{
		for (int i = 0; i < s.Length; ++i) if (s[i] != s[s.Length - 1 - i]) return false;
		return true;
	}
}
0