結果

問題 No.3381 Palindrome Substrings (C++)
コンテスト
ユーザー tRue
提出日時 2025-11-21 22:44:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 322 bytes
コンパイル時間 2,471 ms
コンパイル使用メモリ 194,992 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-11-22 12:39:14
合計ジャッジ時間 3,962 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include"bits/stdc++.h"
using namespace std;

int main() {
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    for(int i=0;i<n;i++)for(int j=i;j<n;j++){
        bool ok=1;
        for(int k=i;k<j;k++)
            if(s[k]!=s[j-(k-i)])
                ok=0;
        ans+=ok;
    }
    cout<<ans<<endl;
    return 0;
}
0