結果
問題 | No.599 回文かい |
ユーザー | htkb |
提出日時 | 2019-02-08 21:05:22 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 721 bytes |
コンパイル時間 | 293 ms |
コンパイル使用メモリ | 87,088 KB |
実行使用メモリ | 282,704 KB |
最終ジャッジ日時 | 2023-09-11 03:05:24 |
合計ジャッジ時間 | 5,249 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
71,072 KB |
testcase_01 | AC | 73 ms
71,204 KB |
testcase_02 | AC | 70 ms
70,992 KB |
testcase_03 | AC | 71 ms
71,132 KB |
testcase_04 | AC | 79 ms
75,452 KB |
testcase_05 | WA | - |
testcase_06 | AC | 73 ms
71,496 KB |
testcase_07 | AC | 73 ms
71,160 KB |
testcase_08 | AC | 71 ms
71,160 KB |
testcase_09 | WA | - |
testcase_10 | AC | 78 ms
75,948 KB |
testcase_11 | AC | 79 ms
76,100 KB |
testcase_12 | AC | 81 ms
75,948 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | MLE | - |
testcase_18 | AC | 72 ms
71,468 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
evil_0.txt | WA | - |
ソースコード
import sys sys.setrecursionlimit(10**6) S = [ord(c) for c in input()] #S = [ord("a")]*(10**4) length = len(S) mod = 10**9+7 left_kc, right_kc = S[:length//2], S[::-1][:length//2] p = 1 for i in range(length//2): left_kc[i] = (left_kc[i] * p) % mod p = p * 10 % mod dp = [0]*length def rec(left): count = 1 left_hash, right_hash = 0, 0 m = 10**left % mod for i, (lc, rc) in enumerate(zip(left_kc[left:length//2], right_kc[left:length//2]), start=left): left_hash = (left_hash + lc) % mod right_hash = (right_hash * 10 + rc*m) % mod if left_hash == right_hash: count = count + (dp[i+1] or rec(i+1)) % mod dp[left] = count return count print(rec(0))