結果

問題 No.238 Mr. K's Another Gift
ユーザー eitahoeitaho
提出日時 2015-07-07 22:43:42
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,694 bytes
コンパイル時間 2,289 ms
コンパイル使用メモリ 108,560 KB
実行使用メモリ 28,808 KB
最終ジャッジ日時 2023-09-22 09:23:34
合計ジャッジ時間 7,702 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
20,632 KB
testcase_01 AC 52 ms
20,500 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 53 ms
21,024 KB
testcase_05 AC 56 ms
23,612 KB
testcase_06 AC 58 ms
24,524 KB
testcase_07 AC 59 ms
26,796 KB
testcase_08 AC 60 ms
28,808 KB
testcase_09 AC 59 ms
28,772 KB
testcase_10 WA -
testcase_11 AC 52 ms
20,516 KB
testcase_12 AC 51 ms
20,640 KB
testcase_13 AC 53 ms
20,464 KB
testcase_14 AC 53 ms
22,104 KB
testcase_15 AC 59 ms
25,260 KB
testcase_16 AC 57 ms
24,440 KB
testcase_17 AC 53 ms
21,436 KB
testcase_18 AC 54 ms
22,496 KB
testcase_19 AC 53 ms
21,308 KB
testcase_20 AC 52 ms
20,520 KB
testcase_21 AC 50 ms
20,572 KB
testcase_22 AC 50 ms
22,496 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 58 ms
26,680 KB
testcase_27 AC 58 ms
26,824 KB
testcase_28 AC 61 ms
26,664 KB
testcase_29 AC 63 ms
26,760 KB
testcase_30 AC 51 ms
20,648 KB
testcase_31 AC 51 ms
22,592 KB
testcase_32 AC 52 ms
22,576 KB
testcase_33 AC 53 ms
22,812 KB
testcase_34 AC 53 ms
21,212 KB
testcase_35 AC 58 ms
26,792 KB
testcase_36 AC 56 ms
23,596 KB
testcase_37 AC 55 ms
22,816 KB
testcase_38 AC 54 ms
22,952 KB
testcase_39 AC 53 ms
21,324 KB
testcase_40 AC 51 ms
20,644 KB
testcase_41 AC 51 ms
20,608 KB
testcase_42 AC 51 ms
22,692 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.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

class Program
{
    static readonly string Bad = "NA";

    public void Solve()
    {
        string S = Reader.String();
        var ans = Rec(S, 0, S.Length - 1, false);
        if (S != Bad && ans == S)
            if (ans.Length % 2 == 0) ans = ans.Insert(ans.Length / 2, "a");
            else ans = ans.Insert(ans.Length / 2, ans[ans.Length / 2] + "");
        Console.WriteLine(ans);
    }

    string Rec(string S, int L, int R, bool inserted)
    {
        if (L >= R) return S;
        if (S[L] == S[R]) return Rec(S, L + 1, R - 1, inserted);
        if (inserted) return Bad;
        var insertL = Rec(S.Insert(L, S[R] + ""), L + 1, R - 1, true);
        if (insertL != Bad) return insertL;
        return Rec(S.Insert(R + 1, S[L] + ""), L + 1, R, true);
    }
}



class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    private static TextReader reader = Console.In;
    private static readonly char[] separator = { ' ' };
    private static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    private static string[] A = new string[0];
    private static int i;
    private static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Enu.Range(0, N).Select(i => Int()).ToArray(); }
    public static int[][] IntTable(int H) { return Enu.Range(0, H).Select(i => IntLine()).ToArray(); }
    public static string[] StringArray(int N) { return Enu.Range(0, N).Select(i => Line()).ToArray(); }
    public static string Line() { return reader.ReadLine().Trim(); }
    private static string[] Split(string s) { return s.Split(separator, op); }
    private static string Next() { CheckNext(); return A[i++]; }
    private static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}
0