-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTheAlphabetStickers.cpp
48 lines (33 loc) · 977 Bytes
/
TheAlphabetStickers.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <bits/stdc++.h>
using namespace std;
typedef long long Int;
const Int MOD = 1000000007LL;
int T, N;
string S;
int main() {
cin >> T;
while (T--) {
cin >> S;
int N = (int) S.size();
Int ans = 1LL;
for (int i = 0; i < N; i++) {
if (S[i] == '?') {
int j = i;
while (j < N && S[j] == '?') {
j += 1;
}
char a = '$';
char b = '$';
if (i - 1 >= 0) a = S[i - 1];
if (j != N) b = S[j];
if (a != '$' && b != '$' && a != b) {
ans *= (Int) (j - i + 1);
ans %= MOD;
}
i = j - 1;
}
}
cout << ans <<"\n";
}
return 0;
}