結果

問題 No.3381 Palindrome Substrings (C++)
コンテスト
ユーザー mkzkm
提出日時 2025-11-22 14:27:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 216 bytes
コンパイル時間 1,828 ms
コンパイル使用メモリ 195,524 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-11-22 14:27:38
合計ジャッジ時間 4,162 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
    4 | main(){int n;string s,p,q;cin>>n>>s;int a=0;r(i,n){p="";r(j,n-i){p+=s[i+j];q=p;reverse(q.begin(),q.end());if(p==q)a++;}}cout<<a<<'\n';}
      | ^~~~

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;++i)
main(){int n;string s,p,q;cin>>n>>s;int a=0;r(i,n){p="";r(j,n-i){p+=s[i+j];q=p;reverse(q.begin(),q.end());if(p==q)a++;}}cout<<a<<'\n';}
0