結果

問題 No.273 回文分解
ユーザー nanophoto12
提出日時 2015-12-07 23:00:09
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 782 bytes
コンパイル時間 1,055 ms
コンパイル使用メモリ 113,460 KB
実行使用メモリ 27,156 KB
最終ジャッジ日時 2024-12-23 13:13:04
合計ジャッジ時間 3,291 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 ();
			var r = new string(s.Reverse ().ToArray());

			int maxMatch = 0;
			for (int i = 1; i < s.Length; i++) {
				int a = 0;
				for (int k = 0; k + i< s.Length; k++) {
					if (s [i + k] == r [k]) {
						a++;
						maxMatch = Math.Max (maxMatch, a);
					} else {
						a = 0;
					}
				}
			}
			for (int i = 0; i < s.Length-1; i++) {
				int a = 0;
				for (int k = 1; k + i< s.Length; k++) {
					if (s [i + k] == r [k]) {
						a++;
						maxMatch = Math.Max (maxMatch, a);
					} else {
						a = 0;
					}
				}
			}
			Console.WriteLine (maxMatch.ToString ());
		}
	}
}
0