結果

問題 No.238 Mr. K's Another Gift
ユーザー 14番14番
提出日時 2016-05-08 21:26:10
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,563 bytes
コンパイル時間 893 ms
コンパイル使用メモリ 112,572 KB
実行使用メモリ 27,808 KB
最終ジャッジ日時 2024-04-15 13:57:43
合計ジャッジ時間 5,494 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 24 ms
21,428 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 24 ms
25,660 KB
testcase_05 WA -
testcase_06 AC 27 ms
25,640 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 24 ms
23,596 KB
testcase_11 AC 24 ms
23,540 KB
testcase_12 AC 24 ms
23,532 KB
testcase_13 AC 25 ms
27,740 KB
testcase_14 AC 25 ms
23,344 KB
testcase_15 AC 25 ms
23,336 KB
testcase_16 AC 27 ms
21,428 KB
testcase_17 AC 25 ms
23,464 KB
testcase_18 AC 25 ms
23,856 KB
testcase_19 AC 26 ms
25,384 KB
testcase_20 AC 25 ms
25,468 KB
testcase_21 AC 24 ms
23,600 KB
testcase_22 AC 24 ms
25,592 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 26 ms
25,484 KB
testcase_27 WA -
testcase_28 AC 26 ms
25,348 KB
testcase_29 WA -
testcase_30 AC 25 ms
25,592 KB
testcase_31 AC 26 ms
25,596 KB
testcase_32 AC 24 ms
23,552 KB
testcase_33 AC 24 ms
23,240 KB
testcase_34 AC 25 ms
25,532 KB
testcase_35 AC 25 ms
25,764 KB
testcase_36 AC 25 ms
23,472 KB
testcase_37 AC 25 ms
23,600 KB
testcase_38 AC 25 ms
23,280 KB
testcase_39 AC 26 ms
23,656 KB
testcase_40 AC 25 ms
25,336 KB
testcase_41 AC 24 ms
23,788 KB
testcase_42 AC 24 ms
23,400 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.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();
    }
}
0