結果
| 問題 |
No.599 回文かい
|
| コンテスト | |
| ユーザー |
バカらっく
|
| 提出日時 | 2017-11-24 23:23:16 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,754 bytes |
| コンパイル時間 | 918 ms |
| コンパイル使用メモリ | 111,408 KB |
| 実行使用メモリ | 51,652 KB |
| 最終ジャッジ日時 | 2024-11-27 08:17:42 |
| 合計ジャッジ時間 | 26,067 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 TLE * 4 |
コンパイルメッセージ
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;
StringBuilder txt1 = new StringBuilder();
StringBuilder txt2 = new StringBuilder();
for (int i = 1; (idx+i)*2<=Text.Length; i++) {
txt1.Append(Text[idx+i-1]);
txt2.Insert(0, (Text[Text.Length - idx - i]));
if(txt1.ToString().Equals(txt2.ToString())) {
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 = @"
aaaaa
";
}
public static void Main(string[] args)
{
#if DEBUG
Reader.IsDebug = true;
#endif
Program prg = new Program();
prg.Proc();
}
}
バカらっく