#include <bits/stdc++.h>
using namespace std;
#define N 50000
bitset<N> vis[6][26], a;
int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL);
int n, m; cin >> n >> m;
string s[n];
for(int i = 0; i < n; i++){
cin >> s[i];
for(int j = 0; j < m; j++) {
if(s[i][j] == '?') for(int k = 0; k < 26; k++) vis[j][k][i] = true;
else vis[j][s[i][j] - 'a'][i] = true;
}
}
for(int i = 0; i < n; i++) a[i] = true;
long long ans = 0;
for(int i = 0; i < n; i++){
a[i] = false;
bitset<N> curr = a;
for(int j = 0; j < m; j++) if(s[i][j] != '?') curr &= vis[j][s[i][j] - 'a'];
ans += curr.count();
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
106 ms |
2148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
76 ms |
1660 KB |
Output is correct |
2 |
Correct |
67 ms |
1668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
113 ms |
2008 KB |
Output is correct |
2 |
Correct |
119 ms |
2348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
78 ms |
1824 KB |
Output is correct |
2 |
Correct |
77 ms |
1876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
121 ms |
2516 KB |
Output is correct |
2 |
Correct |
60 ms |
1748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
151 ms |
2644 KB |
Output is correct |
2 |
Correct |
94 ms |
2480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
113 ms |
2412 KB |
Output is correct |
2 |
Correct |
70 ms |
2236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
147 ms |
2708 KB |
Output is correct |
2 |
Correct |
127 ms |
2908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
123 ms |
2524 KB |
Output is correct |
2 |
Correct |
74 ms |
2496 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
181 ms |
3252 KB |
Output is correct |
2 |
Correct |
161 ms |
3176 KB |
Output is correct |