結果
問題 | No.238 Mr. K's Another Gift |
ユーザー | 14番 |
提出日時 | 2016-05-08 21:54:22 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 22 ms / 2,000 ms |
コード長 | 2,962 bytes |
コンパイル時間 | 929 ms |
コンパイル使用メモリ | 106,496 KB |
実行使用メモリ | 18,048 KB |
最終ジャッジ日時 | 2024-10-05 10:57:40 |
合計ジャッジ時間 | 3,424 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 20 ms
17,408 KB |
testcase_01 | AC | 21 ms
17,408 KB |
testcase_02 | AC | 20 ms
17,408 KB |
testcase_03 | AC | 21 ms
17,280 KB |
testcase_04 | AC | 19 ms
17,152 KB |
testcase_05 | AC | 21 ms
17,792 KB |
testcase_06 | AC | 20 ms
17,280 KB |
testcase_07 | AC | 21 ms
18,048 KB |
testcase_08 | AC | 21 ms
17,792 KB |
testcase_09 | AC | 21 ms
17,536 KB |
testcase_10 | AC | 19 ms
17,408 KB |
testcase_11 | AC | 20 ms
17,408 KB |
testcase_12 | AC | 18 ms
17,408 KB |
testcase_13 | AC | 19 ms
17,280 KB |
testcase_14 | AC | 19 ms
17,276 KB |
testcase_15 | AC | 19 ms
17,404 KB |
testcase_16 | AC | 19 ms
17,536 KB |
testcase_17 | AC | 20 ms
17,536 KB |
testcase_18 | AC | 20 ms
17,408 KB |
testcase_19 | AC | 21 ms
17,280 KB |
testcase_20 | AC | 20 ms
17,408 KB |
testcase_21 | AC | 20 ms
17,408 KB |
testcase_22 | AC | 20 ms
17,408 KB |
testcase_23 | AC | 20 ms
17,280 KB |
testcase_24 | AC | 20 ms
17,280 KB |
testcase_25 | AC | 20 ms
17,248 KB |
testcase_26 | AC | 20 ms
17,408 KB |
testcase_27 | AC | 21 ms
17,664 KB |
testcase_28 | AC | 21 ms
17,280 KB |
testcase_29 | AC | 21 ms
17,792 KB |
testcase_30 | AC | 19 ms
17,536 KB |
testcase_31 | AC | 18 ms
17,408 KB |
testcase_32 | AC | 20 ms
17,280 KB |
testcase_33 | AC | 20 ms
17,408 KB |
testcase_34 | AC | 22 ms
17,416 KB |
testcase_35 | AC | 19 ms
17,280 KB |
testcase_36 | AC | 19 ms
17,408 KB |
testcase_37 | AC | 20 ms
17,292 KB |
testcase_38 | AC | 20 ms
17,536 KB |
testcase_39 | AC | 21 ms
17,280 KB |
testcase_40 | AC | 21 ms
17,536 KB |
testcase_41 | AC | 19 ms
17,408 KB |
testcase_42 | AC | 19 ms
17,408 KB |
コンパイルメッセージ
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) { if(canIns) { return target + target; } else { return target; } } if(topIdx >= bottomIdx) { return target.Substring(0, topIdx) + target[topIdx] + target.Substring(topIdx); } else if(!canIns) { return string.Empty; } else { string mid = target.Substring(topIdx, bottomIdx + 1 - topIdx); string tmp1 = this.GetKaibun(mid.Substring(1), false); if(tmp1.Length == 0) { tmp1 = this.GetKaibun(mid.Substring(0, mid.Length - 1), false); if(tmp1.Length > 0) { mid = mid[mid.Length - 1] + mid; } } else { mid = mid + mid[0]; } if(tmp1.Length > 0) { if(topIdx == 0) { return mid; } else { return target.Substring(0,topIdx) + mid + target.Substring(bottomIdx + 1); } } else { return string.Empty; } } } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" dedc "; 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(); } }