Logo
(追記) (追記ここまで)

22926번 - Ketek Counting 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 64 MB (추가 메모리 없음)60302551.020%

문제

Define a Ketek to be a sentence that reads the same forwards and backwards, by word. For example, 'fall leaves after leaves fall' is a Ketek since the words in reverse order are the same as the original order.

Given a string consisting of lower-case letters and the character '?', count the number of distinct Keteks you can make by replacing every '?' with lower-case letters (one letter per '?'), and optionally adding spaces between any letters. Note that a Ketek cannot contain any ?'s; they all must be replaced exclusively by lower-case letters.

For example, if we start with the string 'ababa', we can form 3 different Keteks: 'ababa', 'a bab a' and 'a b a b a'.

If we start with the string '?x?z' instead, we can form 703 different Keteks:

  • There are 26ドル^2 = 676$ ways to replace the ?'s and form a one-word Ketek.
  • Add spaces to form '? x? z'. There are 26ドル$ ways to form a Ketek (the first '?' must be z; the other can be any lower-case letter).
  • Add a space to form '?x ?z'. There is no way to form a Ketek.
  • Add spaces to form '? x ? z'. There is one way to form a Ketek (the first '?' must be z; the second must be x).

The total is 676ドル + 26 + 0 + 1 = 703$.

Two Keteks are different if they have a different number of words, or there is some word index where the words are not the same.

입력

The single line of input contains a string $s$ (1ドル \le |s| \le 30,000円$), which consists of lower-case letters ('a'--'z') and the character '?'.

출력

Output the number of distinct Keteks that can be formed by replacing the ?'s with lower-case letters and adding spaces. Since this number may be large, output it modulo 998ドル,244円,353円$.

제한

예제 입력 1

ababa

예제 출력 1

3

예제 입력 2

?x?z

예제 출력 2

703

힌트

출처

ICPC > Regionals > North America > North America Championship > North America Championship 2021 E번

Camp > Petrozavodsk Programming Camp > Summer 2021 > Day 2: The American Contest E번

  • 문제를 만든 사람: Lewin Gan
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /