結果

問題 No.599 回文かい
ユーザー バカらっくバカらっく
提出日時 2017-11-24 23:19:39
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,649 bytes
コンパイル時間 810 ms
コンパイル使用メモリ 113,960 KB
実行使用メモリ 29,924 KB
最終ジャッジ日時 2024-05-05 11:33:14
合計ジャッジ時間 6,843 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
23,548 KB
testcase_01 AC 21 ms
23,420 KB
testcase_02 AC 22 ms
23,672 KB
testcase_03 AC 20 ms
23,672 KB
testcase_04 AC 21 ms
23,732 KB
testcase_05 AC 21 ms
25,964 KB
testcase_06 AC 21 ms
25,716 KB
testcase_07 AC 20 ms
25,960 KB
testcase_08 AC 20 ms
23,544 KB
testcase_09 AC 21 ms
23,924 KB
testcase_10 AC 35 ms
29,924 KB
testcase_11 AC 30 ms
29,912 KB
testcase_12 AC 57 ms
29,680 KB
testcase_13 AC 83 ms
27,876 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
evil_0.txt -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        string inpt = Reader.ReadLine();
        this.Text = inpt;
        dic = new Nullable<long>[this.Text.Length];
        long ans = GetAns(0);
        Console.WriteLine(ans);
    }

    private string Text;

    private Nullable<long>[] dic;

    private long Mod = 1000000000 + 7;
    private long GetAns(int idx) {
        if(dic[idx] != null) {
            return dic[idx].Value;
        }
        long ans = 1;
        for (int i = 1; (idx+i)*2<=Text.Length; i++) {
            string txt1 = Text.Substring(idx, i);
            string txt2 = Text.Substring(Text.Length - idx - i, i);
            if(txt1.Equals(txt2)) {
                ans += GetAns(idx + i);
                ans = ans % Mod;
            }
        }
        dic[idx] = ans;
        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 = @"




aba





";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}
0