#abc301f. F - Anti-DDoS

F - Anti-DDoS

Score : 500500 points

问题描述

一个DDoS类型的字符串是一个长度为 44 的字符串,由大写和小写英文字母组成,并满足以下两个条件。

  • 第一、二个字符和第四个字符是大写英文字母,第三个字符是小写英文字母。
  • 第一和第二个字符相同。

例如,DDoSAAaADDoS 类型的字符串,而 ddosIPoE 都不是。

给定一个包含大写和小写英文字母及 ? 的字符串 SS。设 qq 为字符串 SS? 出现的次数。通过独立地将 SS 中的每个 ? 替换为一个大写或小写英文字母,可以得到 52q52^q 个不同的字符串。在这些字符串中,求出不含 DDoS 类型子序列的字符串的数量,结果对 998244353998244353 取模。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

A DDoS-type string is a string of length 44 consisting of uppercase and lowercase English letters satisfying both of the following conditions.

  • The first, second, and fourth characters are uppercase English letters, and the third character is a lowercase English letter.
  • The first and second characters are equal.

For instance, DDoS and AAaA are DDoS-type strings, while neither ddos nor IPoE is.

You are given a string SS consisting of uppercase and lowercase English letters and ?. Let qq be the number of occurrences of ? in SS. There are 52q52^q strings that can be obtained by independently replacing each ? in SS with an uppercase or lowercase English letter. Among these strings, find the number of ones that do not contain a DDoS-type string as a subsequence, modulo 998244353998244353.

Notes

A subsequence of a string is a string obtained by removing zero or more characters from the string and concatenating the remaining characters without changing the order.
For instance, AC is a subsequence of ABC, while RE is not a subsequence of ECR.

Constraints

  • SS consists of uppercase English letters, lowercase English letters, and ?.
  • The length of SS is between 44 and 3×1053\times 10^5, inclusive.

Input

The input is given from Standard Input in the following format:

SS

Output

Print the answer.

Sample Input 1

DD??S

Sample Output 1

676

When at least one of the ?s is replaced with a lowercase English letter, the resulting string will contain a DDoS-type string as a subsequence.

Sample Input 2

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

Sample Output 2

858572093

Find the count modulo 998244353998244353.

Sample Input 3

?D??S

Sample Output 3

136604

update @ 2024/3/10 08:27:58