QOJ.ac

QOJ

Time Limit: 6 s Memory Limit: 1024 MB Total points: 100

#5474. 信じられないほどかわいいペンギンのひな

Statistics

信じられないほどかわいいペンギンのひなたちは、虫を食べるのが大好きです。ある日、母親は、いくつもの文字が書かれた長いひも状の虫を見つけました。母親は、この虫を切り分けてひなたちに食べさせることにしました。

problem_5474_c8b09a30be05cdcdd5460cb049489f73.png

ひなたちはなぜか International Collegiate Programming Contest が大好きで、ICPC らしい文字列が書かれた部分を食べたがっています。ここで、文字列が ICPC らしいとは、次の条件を満たすことをいいます。

  • C、I、P のみからなります。

  • この三文字のうち二文字は同じ回数(0 回でもかまいません)現れ、残りの一文字はそれより厳密に多く現れます。

例えば、ICPC と PPPPPP は ICPC らしいですが、PIC、PIPCCC、PIPE はそうではありません。

母親が見つけた虫に書かれた文字列が与えられます。母親は余りを無駄にすることなく、すべてに ICPC らしい文字列が書かれるよう、虫を一つ以上の部分にして与えたいと考えています。このように虫を準備する方法の数を数えてください。

入力

入力は、母親が見つけたひも状の虫に書かれた、C、I、P のみからなる文字列 $S$ を含む一行です。$S$ の長さは $1$ 以上 $10^6$ 以下です。

出力

文字列 $S$ を一つ以上の ICPC らしい文字列の連結として表す方法の数を、素数 $998\,244\,353=2^{23}\times7\times17+1$ で割った余りを一行に出力してください。

入出力例

入力 1

ICPC

出力 1

2

入力 2

CCCIIIPPP

出力 2

69

入力 3

PICCICCIPPI

出力 3

24

最初の入出力例では、文字列 ICPC は次の二通りで表せます。

  • 一つの ICPC らしい文字列 ICPC。

  • 四つの ICPC らしい文字列 I、C、P、C の連結。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.