問題一覧 > ショートコード

No.3382 Palindrome Substrings (Python)

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 23
作問者 : alcea / テスター : tRue naka9 Rho 259-Momone
お気に入りにしたユーザー ProblemId : 12858 / 自分の提出
問題文最終更新日: 2025-11-22 11:13:25
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest TSG LIVE! 15 コードゴルフコンテスト (順位表) の他の問題:

Problem Statement

You are given a string $S$ of length $N$ consisting of lowercase English letters. Find the number of non-empty (contiguous) substrings of $S$ that are palindromes.
Substrings that are identical as strings are counted separately if they are taken from different positions.

Input

$N$
$S$

  • $1\leq N \leq 500$
  • $N$ is an integer
  • $S$ is a string of length $N$ consisting of lowercase English letters

Output

Print a newline at the end.

Score

Intended solution: $73$ bytes

Score formula When the code length of a submitted source code is $x$ and the code length of the intended solution of this problem is $y$, the score of that source code is calculated as follows.
  • If $y\leq x$: $\lfloor100\exp(-0.012(x-y))\rfloor$ points
  • If $x<y$: $101$ points
The score for this problem is the maximum score among the source codes submitted to this problem.

Sample

Sample 1
Input
5
aabab
Output
8

The $8$ palindromic substrings are a a b a b aa aba bab.

Sample 2
Input
4
wwww
Output
10

Sample 3
Input
23
theoreticalsciencegroup
Output
23

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。