結果
問題 |
No.464 PPAP
|
ユーザー |
|
提出日時 | 2022-01-28 10:03:22 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 945 bytes |
コンパイル時間 | 214 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 151,288 KB |
最終ジャッジ日時 | 2024-12-28 03:09:36 |
合計ジャッジ時間 | 28,568 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 18 TLE * 4 |
ソースコード
import numpy as np def substring_palindrome(S): L = len(S) table = np.zeros((L, L), dtype=bool) for i in range(L): # 奇数長 j = 0 while 0 <= i - j and i + j < L: if S[i - j] == S[i + j]: table[i - j][i + j] = True j += 1 else: break # 偶数長 j = 0 while 0 <= i - j and i + j + 1 < L: if S[i - j] == S[i + j + 1]: table[i - j][i + j + 1] = True j += 1 else: break return table S = input() L = len(S) P, PP, PPA, PPAP = (np.zeros(L, dtype=np.int64) for _ in range(4)) table = np.array(substring_palindrome(S)) for i in range(L): # PPAP PPAP[i] = np.sum(PPA[:-1] * table[1:, i]) # PPA PPA[i] = np.sum(PP[:i]) # PP PP[i] = np.sum(P[:-1] * table[1:, i]) # P P[i] = table[0, i] print(PPAP[-1])