結果

問題 No.599 回文かい
ユーザー sibasyunsibasyun
提出日時 2023-12-15 11:32:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 862 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 18,196 KB
最終ジャッジ日時 2023-12-15 11:32:53
合計ジャッジ時間 6,741 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,112 KB
testcase_01 AC 30 ms
10,112 KB
testcase_02 AC 30 ms
10,112 KB
testcase_03 AC 29 ms
10,112 KB
testcase_04 AC 30 ms
10,112 KB
testcase_05 AC 34 ms
10,112 KB
testcase_06 AC 30 ms
10,112 KB
testcase_07 AC 30 ms
10,112 KB
testcase_08 AC 31 ms
10,112 KB
testcase_09 AC 32 ms
10,112 KB
testcase_10 AC 41 ms
10,240 KB
testcase_11 AC 40 ms
10,240 KB
testcase_12 AC 64 ms
10,240 KB
testcase_13 AC 104 ms
10,240 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
evil_0.txt -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import io
import sys
import bisect
import math
from itertools import permutations, combinations
from heapq import heappush, heappop
from collections import deque
from collections import defaultdict as dd
sys.setrecursionlimit(10**7+10)

# mod = 998244353
mod = 10**9+7

_INPUT = """\
aaaaa


"""



def main():
    T = input()
    N = len(T)
    dp = [-1 for _ in range(N+1)] # 区間l,rのときのケース数
    def dfs(l):
        if dp[l] != -1:
            return dp[l]
        else:
            r = N-l
            ret = 1
            for i in range(r-l):
                if l+i>=r-1-i:break
                if T[l:l+i+1] == T[r-1-i:r]:
                    ret += dfs(l+i+1)
                    ret %= mod
        dp[l] = ret
        return ret
    dfs(0)
    print(dp[0]%mod)

if __name__ == "__main__":
    # sys.stdin = io.StringIO(_INPUT)
    main()
0