Universal Cup Judging System

Universal Cup

Time Limit: 2.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

החיים תמיד מלאים בחוסר ודאות. לדוגמה, אתם עשויים לחשוב מכותרת הבעיה שזוהי בעיית מחרוזות, אך למעשה היא לא.

נתונים לכם מחרוזת $s$ ותו $c$. בכל פעם, אתם בוחרים באקראי מיקום $i$ שטרם נבחר קודם לכן, ומשנים את $s_i$ ל-$c$ (אם $s_i = c$, זה עדיין נחשב כפעולה אחת). אתם חוזרים על פעולה זו עד ש-$s$ הופכת לפלינדרום, ואז עוצרים. ברצונכם לדעת את תוחלת מספר הפעולות הדרושות.

בפרט, אם $s$ היא כבר פלינדרום בהתחלה, התשובה היא $0$.

קלט

השורה הראשונה מכילה מחרוזת $s$ ($1 \le |s| \le 250000$), שמובטח כי היא מורכבת רק מאותיות אנגליות קטנות.

השורה השנייה מכילה אות אנגלית קטנה $c$.

פלט

הדפיסו מספר שלם אחד בשורה בודדת, המייצג את התוחלת מודולו $998244353$.

דוגמאות

קלט 1

abcab
a

פלט 1

4

קלט 2

abcdcbd
a

פלט 2

177465668

קלט 3

aba
z

פלט 3

0

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.