結果

問題 No.599 回文かい
ユーザー torikuminotorikumino
提出日時 2019-05-04 15:26:49
言語 PyPy3
(7.3.13)
結果
TLE  
実行時間 -
コード長 351 bytes
コンパイル時間 1,879 ms
コンパイル使用メモリ 86,748 KB
実行使用メモリ 83,468 KB
最終ジャッジ日時 2023-09-05 02:15:35
合計ジャッジ時間 19,183 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,020 KB
testcase_01 AC 72 ms
71,188 KB
testcase_02 AC 73 ms
71,372 KB
testcase_03 AC 72 ms
71,380 KB
testcase_04 AC 98 ms
77,084 KB
testcase_05 AC 95 ms
76,740 KB
testcase_06 AC 95 ms
76,828 KB
testcase_07 AC 101 ms
76,696 KB
testcase_08 AC 99 ms
76,716 KB
testcase_09 AC 96 ms
76,860 KB
testcase_10 AC 3,104 ms
79,120 KB
testcase_11 AC 1,869 ms
78,252 KB
testcase_12 AC 3,492 ms
78,620 KB
testcase_13 AC 2,060 ms
78,168 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]
            dp[i] %= p
print(dp[0])
0