結果
問題 | No.599 回文かい |
ユーザー |
![]() |
提出日時 | 2017-11-24 23:19:39 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,649 bytes |
コンパイル時間 | 852 ms |
コンパイル使用メモリ | 106,496 KB |
実行使用メモリ | 43,384 KB |
最終ジャッジ日時 | 2024-11-27 08:13:34 |
合計ジャッジ時間 | 22,166 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 TLE * 3 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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(); } }