結果
| 問題 | No.3381 Palindrome Substrings (C++) |
| コンテスト | |
| ユーザー |
a01sa01to
|
| 提出日時 | 2025-11-26 00:25:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 20 ms / 2,000 ms |
| コード長 | 527 bytes |
| 記録 | |
| コンパイル時間 | 1,809 ms |
| コンパイル使用メモリ | 195,900 KB |
| 実行使用メモリ | 7,848 KB |
| スコア | 0 |
| 最終ジャッジ日時 | 2025-11-26 00:25:23 |
| 合計ジャッジ時間 | 4,303 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
inline bool is_palindrome(string s) {
string t = s;
reverse(t.begin(), t.end());
return s == t;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n;
string s;
cin >> n >> s;
int ans = 0;
rep(i, n) rep(len, n + 1) {
if (len == 0) continue;
if (i + len <= n && is_palindrome(s.substr(i, len))) ++ans;
}
cout << ans << '\n';
return 0;
}
a01sa01to