結果
| 問題 |
No.588 空白と回文
|
| コンテスト | |
| ユーザー |
バカらっく
|
| 提出日時 | 2017-11-03 22:55:01 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,274 bytes |
| コンパイル時間 | 1,023 ms |
| コンパイル使用メモリ | 115,564 KB |
| 実行使用メモリ | 34,908 KB |
| 最終ジャッジ日時 | 2024-11-22 16:14:36 |
| 合計ジャッジ時間 | 24,259 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 TLE * 7 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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();
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] = ' ';
}
ans = Math.Max(ans, tmp.Skip(fromIdx).Take(i * 2 + 1).Count(a => a != ' '));
}
tmp = target.ToArray();
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] = ' ';
}
ans = Math.Max(ans, tmp.Skip(fromidx).Take(i * 2).Count(a => a != ' '));
}
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();
}
}
バカらっく