結果

問題 No.1617 Palindrome Removal
ユーザー さかぽんさかぽん
提出日時 2021-07-22 23:08:36
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 781 bytes
コンパイル時間 2,905 ms
コンパイル使用メモリ 104,824 KB
実行使用メモリ 26,796 KB
最終ジャッジ日時 2023-09-24 19:04:52
合計ジャッジ時間 6,072 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
24,748 KB
testcase_01 AC 97 ms
24,740 KB
testcase_02 AC 97 ms
24,556 KB
testcase_03 AC 95 ms
26,604 KB
testcase_04 AC 97 ms
26,796 KB
testcase_05 AC 89 ms
25,940 KB
testcase_06 AC 62 ms
26,612 KB
testcase_07 AC 59 ms
23,060 KB
testcase_08 AC 51 ms
21,236 KB
testcase_09 AC 52 ms
21,264 KB
testcase_10 AC 94 ms
26,520 KB
testcase_11 AC 90 ms
23,960 KB
testcase_12 AC 96 ms
24,764 KB
testcase_13 AC 96 ms
24,776 KB
testcase_14 AC 54 ms
21,360 KB
testcase_15 AC 52 ms
21,356 KB
testcase_16 AC 54 ms
21,452 KB
testcase_17 AC 54 ms
21,256 KB
testcase_18 AC 54 ms
21,244 KB
testcase_19 AC 54 ms
21,244 KB
testcase_20 AC 56 ms
23,500 KB
testcase_21 AC 55 ms
21,412 KB
testcase_22 AC 58 ms
23,452 KB
testcase_23 AC 55 ms
21,428 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 (n == 1) return -1;

		if (n == 3)
		{
			if (!IsPalindrome(s)) return n;
			return -1;
		}

		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