結果
問題 |
No.238 Mr. K's Another Gift
|
ユーザー |
![]() |
提出日時 | 2016-05-08 21:26:10 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,563 bytes |
コンパイル時間 | 1,247 ms |
コンパイル使用メモリ | 106,112 KB |
実行使用メモリ | 17,664 KB |
最終ジャッジ日時 | 2024-10-05 10:56:42 |
合計ジャッジ時間 | 5,148 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 WA * 12 |
コンパイルメッセージ
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; class Program { public void Proc() { Reader.IsDebug = false; string str = Reader.ReadLine(); string ans = this.GetKaibun(str, true); if(ans.Length == 0) { ans = "NA"; } Console.WriteLine(ans); } private string GetKaibun(string target, bool canIns) { int topIdx = 0; int bottomIdx = target.Length - 1; while (target[topIdx] == target[bottomIdx] && topIdx < bottomIdx) { topIdx++; bottomIdx--; } if(target.Length == 1) { return target; } if(topIdx >= bottomIdx) { return target.Substring(0, topIdx) + target[topIdx] + target.Substring(topIdx); } else if(!canIns) { return string.Empty; } else { string tmp1 = this.GetKaibun(target.Substring(1), false); if(tmp1.Length == 0) { tmp1 = this.GetKaibun(target.Substring(0, target.Length - 1), false); if(tmp1.Length == 0) { return string.Empty; } else { return target[target.Length - 1] + target; } } else { return target + target[0]; } } } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" kitayuta "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } public static int[] GetInt(char delimiter = ' ', bool trim = false) { string inptStr = ReadLine(); if (trim) { inptStr = inptStr.Trim(); } string[] inpt = inptStr.Split(delimiter); int[] ret = new int[inpt.Length]; for (int i = 0; i < inpt.Length; i++) { ret[i] = int.Parse(inpt[i]); } return ret; } } static void Main() { Program prg = new Program(); prg.Proc(); } }