結果
問題 | No.599 回文かい |
ユーザー |
|
提出日時 | 2017-11-24 22:34:53 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 718 bytes |
コンパイル時間 | 750 ms |
コンパイル使用メモリ | 110,332 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 22:37:17 |
合計ジャッジ時間 | 2,627 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 WA * 1 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;import std.typecons, std.range, std.random, std.math, std.container;import std.numeric, std.bigint, core.bitop;const long MOD = 10^^9 + 7;void main() {auto S = readln.chomp;auto N = S.length.to!int;auto mem = new long[](N);mem.fill(-1);long dfs(int l) {if (l >= N/2)return 0;if (mem[l] >= 0)return mem[l];int r = N - l - 1;long ret = 0;foreach (i; l..N/2) {if (S[l..i+1] == S[N-i-1..r+1]) {(ret += dfs(i+1) + 1) %= MOD;}}mem[l] = ret;return ret;}writeln(dfs(0)+1);}