QOJ.ac

QOJ

Time Limit: 3.0 s Memory Limit: 2048 MB

#22862. خذ الكثير من ABA

Statistics

لكل سلسلة نصية $T$ تتكون من A و B، نعرّف $f(T)$ على أنه أكبر عدد من المرات التي يمكن فيها تنفيذ العملية التالية.

العملية: احذف ABA التي تظهر كمتتالية فرعية (ليست بالضرورة متجاورة) من $T$، وأغلق الفجوات الناتجة.

تُعطى لك سلسلة نصية $S$ تتكون من A و B و ?. أوجد مجموع $f(T)$ على جميع السلاسل النصية $T$ الناتجة عن استبدال كل ? في $S$ إما بالحرف A أو بالحرف B، باقي القسمة على $998244353$.

الإدخال

يُعطى الإدخال بالصيغة التالية:

$$S$$

$S$ هي سلسلة نصية تتكون من A و B و ?، ويتراوح طولها بين $3$ و $1000$ شاملاً الحدين.

الإخراج

اطبع الإجابة.

أمثلة

الإدخال 1

A?B?

الإخراج 1

2

الإدخال 2

?B?A?B?

الإخراج 2

15

الإدخال 3

????????????????????

الإخراج 3

4595728

ملاحظة

السلاسل النصية $T$ الممكنة وقيم $f(T)$ المقابلة لها في المثال الأول هي كما يلي:

  • $T = \texttt{AABA}$: $f(T) = 1$.
  • $T = \texttt{AABB}$: $f(T) = 0$.
  • $T = \texttt{ABBA}$: $f(T) = 1$.
  • $T = \texttt{ABBB}$: $f(T) = 0$.

وبالتالي، فإن الإجابة هي $1 + 0 + 1 + 0 = 2$.

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.