結果

問題 No.599 回文かい
ユーザー shotoyooshotoyoo
提出日時 2021-09-26 10:23:58
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 852 bytes
コンパイル時間 549 ms
コンパイル使用メモリ 87,004 KB
実行使用メモリ 77,612 KB
最終ジャッジ日時 2023-09-19 02:50:08
合計ジャッジ時間 9,608 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,288 KB
testcase_01 AC 72 ms
71,064 KB
testcase_02 AC 73 ms
70,956 KB
testcase_03 AC 79 ms
71,244 KB
testcase_04 AC 84 ms
75,660 KB
testcase_05 WA -
testcase_06 AC 86 ms
75,656 KB
testcase_07 AC 85 ms
75,668 KB
testcase_08 AC 86 ms
75,624 KB
testcase_09 WA -
testcase_10 AC 589 ms
76,964 KB
testcase_11 AC 360 ms
76,812 KB
testcase_12 AC 657 ms
77,012 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 75 ms
71,108 KB
testcase_19 WA -
testcase_20 WA -
evil_0.txt WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))

def sub(s):
    s = [ord(c) for c in s]
    b = 128
    cum = [0]
    v = 1
    for i in range(len(s)):
        v *= b
        v %= M
        cum.append(cum[-1] + v*s[i]%M)
    bs = [1]
    for _ in range(len(s)+10):
        bs.append(bs[-1]*b%M)
    n = len(s)
    m = (n)//2 + 1
    dp = [0]*(m)
    dp[0] = 1
    for i in range(1,m):
        val = 0
        for j in range(i):
#             if s[j:i]==s[n-i:n-j]:
            if ((cum[i]-cum[j])*bs[n-j-i]%M == (cum[n-j]-cum[n-i])%M):
                val += dp[j]
                if val>M:
                    val -= M
        dp[i] = val%M
    return sum(dp)
M = 10**9+7
s = input()
ans = sub(s)
print(ans)
0