結果
| 問題 | 
                            No.465 PPPPPPPPPPPPPPPPAPPPPPPPP
                             | 
                    
| コンテスト | |
| ユーザー | 
                             gew1fw
                         | 
                    
| 提出日時 | 2025-06-12 14:58:58 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 832 bytes | 
| コンパイル時間 | 261 ms | 
| コンパイル使用メモリ | 82,288 KB | 
| 実行使用メモリ | 86,236 KB | 
| 最終ジャッジ日時 | 2025-06-12 14:59:54 | 
| 合計ジャッジ時間 | 4,191 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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