結果
| 問題 | No.273 回文分解 | 
| コンテスト | |
| ユーザー |  nanophoto12 | 
| 提出日時 | 2015-12-08 00:57:39 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 25 ms / 2,000 ms | 
| コード長 | 929 bytes | 
| コンパイル時間 | 1,054 ms | 
| コンパイル使用メモリ | 109,732 KB | 
| 実行使用メモリ | 25,936 KB | 
| 最終ジャッジ日時 | 2024-06-25 13:33:11 | 
| 合計ジャッジ時間 | 2,664 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 32 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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 ());
		}
	}
}
            
            
            
        