結果

問題 No.273 回文分解
ユーザー nanophoto12nanophoto12
提出日時 2015-12-08 00:57:39
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 929 bytes
コンパイル時間 1,999 ms
コンパイル使用メモリ 101,904 KB
実行使用メモリ 22,600 KB
最終ジャッジ日時 2023-09-07 19:47:18
合計ジャッジ時間 5,235 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
20,496 KB
testcase_01 AC 51 ms
20,464 KB
testcase_02 AC 51 ms
22,572 KB
testcase_03 AC 50 ms
20,416 KB
testcase_04 AC 50 ms
20,584 KB
testcase_05 AC 51 ms
20,496 KB
testcase_06 AC 51 ms
22,540 KB
testcase_07 AC 50 ms
22,556 KB
testcase_08 AC 51 ms
22,600 KB
testcase_09 AC 50 ms
20,656 KB
testcase_10 AC 50 ms
20,496 KB
testcase_11 AC 51 ms
20,504 KB
testcase_12 AC 52 ms
20,436 KB
testcase_13 AC 51 ms
20,636 KB
testcase_14 AC 50 ms
20,516 KB
testcase_15 AC 52 ms
20,520 KB
testcase_16 AC 51 ms
20,512 KB
testcase_17 AC 50 ms
18,372 KB
testcase_18 AC 52 ms
22,460 KB
testcase_19 AC 52 ms
20,512 KB
testcase_20 AC 51 ms
22,596 KB
testcase_21 AC 51 ms
22,536 KB
testcase_22 AC 50 ms
20,516 KB
testcase_23 AC 51 ms
20,468 KB
testcase_24 AC 51 ms
20,640 KB
testcase_25 AC 51 ms
20,596 KB
testcase_26 AC 51 ms
20,508 KB
testcase_27 AC 50 ms
20,632 KB
testcase_28 AC 51 ms
22,552 KB
testcase_29 AC 51 ms
20,544 KB
testcase_30 AC 50 ms
20,428 KB
testcase_31 AC 50 ms
20,488 KB
testcase_32 AC 50 ms
20,636 KB
testcase_33 AC 51 ms
22,552 KB
testcase_34 AC 51 ms
20,504 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;
using System.Text;

namespace No273
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			var s = Console.ReadLine ();

			int maxMatch = 1;
			for (int i = 1; i < s.Length; i++) {
				for (int k = i + 1; k < s.Length; k++) {
					bool match = true;
					for (int j = 0; j + i <= k; j++) {
						if (s [i + j] != s [k - j]) {
							match = false;
							break;
						}
					}
					if (match) {
						maxMatch = Math.Max (maxMatch, k - i + 1);
					}
				}
			}
			for (int i = 0; i < s.Length - 1; i++) {
				for (int k = i + 1; k < s.Length - 1; k++) {
					bool match = true;
					for (int j = 0; j + i <= k; j++) {
						if (s [i + j] != s [k - j]) {
							match = false;
							break;
						}
					}
					if (match) {
						maxMatch = Math.Max (maxMatch, k - i + 1);
					}
				}
			}
			Console.WriteLine (maxMatch.ToString ());
		}
	}
}
0