結果
問題 | No.599 回文かい |
ユーザー | convexineq |
提出日時 | 2021-02-14 01:26:45 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 633 bytes |
コンパイル時間 | 385 ms |
コンパイル使用メモリ | 86,956 KB |
実行使用メモリ | 102,960 KB |
最終ジャッジ日時 | 2023-09-28 10:52:02 |
合計ジャッジ時間 | 9,739 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 72 ms
71,348 KB |
testcase_01 | AC | 71 ms
71,480 KB |
testcase_02 | AC | 72 ms
71,240 KB |
testcase_03 | AC | 76 ms
71,440 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
evil_0.txt | WA | - |
ソースコード
def Z_algorithm(s): n = len(s) z = [0]*n z[0] = n i = 1 j = 0 while i < n: while i+j < n and s[j] == s[i+j]: j += 1 z[i] = j if j == 0: i += 1 continue k = 1 while i+k < n and k+z[k] < j: z[i+k] = z[k] k += 1 i += k j -= k return z s = input() n = len(s) v = (n-1)//2 dp = [1]*(v+1) for i in range(v+1)[::-1]: #print(s[i:n-i]) z = Z_algorithm(s[i:n-i]) for k in range(1,v-i+1): if z[n-2*i-k] == k: dp[i] += dp[i+k] #print(s[i+k:n-k-i]) print(dp[0])