結果

問題 No.1617 Palindrome Removal
ユーザー さかぽんさかぽん
提出日時 2021-07-22 23:54:25
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 708 bytes
コンパイル時間 5,060 ms
コンパイル使用メモリ 107,060 KB
実行使用メモリ 26,836 KB
最終ジャッジ日時 2023-09-24 20:34:36
合計ジャッジ時間 6,362 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
24,488 KB
testcase_01 AC 98 ms
24,696 KB
testcase_02 AC 96 ms
24,588 KB
testcase_03 AC 95 ms
24,704 KB
testcase_04 AC 98 ms
24,768 KB
testcase_05 AC 89 ms
25,976 KB
testcase_06 AC 63 ms
26,572 KB
testcase_07 AC 59 ms
25,100 KB
testcase_08 AC 53 ms
21,272 KB
testcase_09 AC 53 ms
21,364 KB
testcase_10 AC 97 ms
26,512 KB
testcase_11 AC 90 ms
24,004 KB
testcase_12 AC 97 ms
22,852 KB
testcase_13 AC 98 ms
26,836 KB
testcase_14 AC 57 ms
23,448 KB
testcase_15 AC 58 ms
21,256 KB
testcase_16 AC 55 ms
19,396 KB
testcase_17 AC 58 ms
21,420 KB
testcase_18 AC 57 ms
21,184 KB
testcase_19 AC 56 ms
21,528 KB
testcase_20 AC 57 ms
23,420 KB
testcase_21 AC 56 ms
21,404 KB
testcase_22 AC 57 ms
23,488 KB
testcase_23 AC 56 ms
21,516 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 (n == 3) return -1;
		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