atcoder#ABC301F. [ABC301F] Anti-DDoS
[ABC301F] Anti-DDoS
Score : points
Problem Statement
A DDoS
-type string is a string of length 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 consisting of uppercase and lowercase English letters and ?
.
Let be the number of occurrences of ?
in . There are strings that can be obtained by independently replacing each ?
in 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 .
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
- consists of uppercase English letters, lowercase English letters, and
?
. - The length of is between and , inclusive.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
DD??S
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.
????????????????????????????????????????
858572093
Find the count modulo .
?D??S
136604