結果
| 問題 |
No.273 回文分解
|
| コンテスト | |
| ユーザー |
nanophoto12
|
| 提出日時 | 2015-12-08 00:48:51 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 925 bytes |
| コンパイル時間 | 820 ms |
| コンパイル使用メモリ | 111,032 KB |
| 実行使用メモリ | 28,092 KB |
| 最終ジャッジ日時 | 2024-12-23 13:13:07 |
| 合計ジャッジ時間 | 2,702 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 9 WA * 23 |
コンパイルメッセージ
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 + i < s.Length; k++) {
bool match = true;
for (int j = 0; j + i <= k; j++) {
if (s [j] != s [k - j]) {
match = false;
break;
}
}
if (match) {
maxMatch = Math.Max (maxMatch, k - i);
}
}
}
for (int i = 0; i < s.Length - 1; i++) {
for (int k = i + 1; k + i < 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);
}
}
}
Console.WriteLine (maxMatch.ToString ());
}
}
}
nanophoto12