結果

問題 No.599 回文かい
ユーザー torikuminotorikumino
提出日時 2019-05-04 15:16:15
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 331 bytes
コンパイル時間 345 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 78,684 KB
最終ジャッジ日時 2023-09-04 21:36:57
合計ジャッジ時間 17,795 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,008 KB
testcase_01 AC 71 ms
70,820 KB
testcase_02 AC 71 ms
71,336 KB
testcase_03 AC 70 ms
71,184 KB
testcase_04 AC 99 ms
76,164 KB
testcase_05 AC 94 ms
76,484 KB
testcase_06 AC 101 ms
76,472 KB
testcase_07 AC 103 ms
76,616 KB
testcase_08 AC 101 ms
76,784 KB
testcase_09 AC 97 ms
76,740 KB
testcase_10 AC 3,098 ms
78,496 KB
testcase_11 AC 1,869 ms
78,112 KB
testcase_12 AC 3,523 ms
78,684 KB
testcase_13 AC 2,067 ms
78,596 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
evil_0.txt -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()
p = 10**9+7
m = 2**64
h, w = [0], [1]
for c in s:
    h.append((h[-1]*p+ord(c))%m)
    w.append(w[-1]*p%m)
def H(i, j):
    return (h[j]-h[i]*w[j-i])%m
n = len(s)//2+1
dp = [1]*n
for i in range(n)[::-1]:
    for j in range(i+1, n):
        if H(i, j) == H(len(s)-j, len(s)-i):
            dp[i] += dp[j] 
print(dp[0]%p)
0