結果

問題 No.588 空白と回文
ユーザー バカらっくバカらっく
提出日時 2017-11-03 22:57:20
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 2,308 bytes
コンパイル時間 792 ms
コンパイル使用メモリ 106,240 KB
実行使用メモリ 22,528 KB
最終ジャッジ日時 2024-11-22 16:14:56
合計ジャッジ時間 2,362 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class Program
{
public void Proc()
{
string inpt = Reader.ReadLine();
int ans = 0;
for (int i = 0; i < inpt.Length; i++) {
ans = Math.Max(ans, GetMaxTaisyo(i, inpt));
}
Console.WriteLine(ans);
}
private int GetMaxTaisyo(int idx, String target) {
int ans = 1;
char[] tmp = target.ToArray();
int cnt = 1;
for (int i = 1; i < target.Length; i++) {
int fromIdx = idx - i;
int toIdx = idx + i;
if (fromIdx < 0) {
break;
}
if(toIdx >= target.Length) {
break;
}
if(tmp[idx-i]!=tmp[idx+i]) {
tmp[idx - i] = ' ';
tmp[idx + i] = ' ';
} else {
cnt += 2;
}
ans = Math.Max(ans, cnt);
}
tmp = target.ToArray();
cnt = 0;
for (int i = 1; i < target.Length; i++) {
int fromidx = idx - i + 1;
int toIdx = idx + i;
if (fromidx < 0)
{
break;
}
if (toIdx >= target.Length)
{
break;
}
if(tmp[fromidx] != tmp[toIdx]) {
tmp[fromidx] = ' ';
tmp[toIdx] = ' ';
} else {
cnt += 2;
}
ans = Math.Max(ans, cnt);
}
return ans;
}
public class Reader
{
private static StringReader sr;
public static bool IsDebug = false;
public static string ReadLine()
{
if (IsDebug)
{
if (sr == null)
{
sr = new StringReader(InputText.Trim());
}
return sr.ReadLine();
}
else
{
return Console.ReadLine();
}
}
private static string InputText = @"
1145141919810
";
}
public static void Main(string[] args)
{
#if DEBUG
Reader.IsDebug = true;
#endif
Program prg = new Program();
prg.Proc();
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0