結果
| 問題 |
No.465 PPPPPPPPPPPPPPPPAPPPPPPPP
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 19:57:39 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 832 bytes |
| コンパイル時間 | 173 ms |
| コンパイル使用メモリ | 82,480 KB |
| 実行使用メモリ | 86,644 KB |
| 最終ジャッジ日時 | 2025-06-12 19:59:59 |
| 合計ジャッジ時間 | 3,915 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 TLE * 1 -- * 17 |
ソースコード
def main():
import sys
S = sys.stdin.readline().strip()
n = len(S)
if n < 4:
print(0)
return
is_prefix_pal = [False] * (n + 1)
is_suffix_pal = [False] * (n + 1)
for i in range(1, n + 1):
s = S[:i]
if s == s[::-1]:
is_prefix_pal[i] = True
for k in range(n):
s = S[k:]
if s == s[::-1]:
is_suffix_pal[k] = True
total = 0
for i in range(1, n - 2 + 1):
if not is_prefix_pal[i]:
continue
for k in range(i + 2, n):
if not is_suffix_pal[k]:
continue
count = 0
for j in range(i + 1, k):
if S[i:j] == S[i:j][::-1]:
count += 1
total += count
print(total)
if __name__ == "__main__":
main()
gew1fw