#include<bits/stdc++.h>
using namespace std;
const int N = 5e4;
bitset < N > q[6][26], a;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
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++){
q[j][k][i] = true;
}
}
else{
q[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 > cur = a;
for(int j = 0; j < m; j++){
if(s[i][j] == '?'){
continue;
}
cur &= q[j][s[i][j] - 'a'];
}
ans += cur.count();
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
181 ms |
2176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
126 ms |
1664 KB |
Output is correct |
2 |
Correct |
121 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
156 ms |
2060 KB |
Output is correct |
2 |
Correct |
215 ms |
2408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
153 ms |
1884 KB |
Output is correct |
2 |
Correct |
159 ms |
1912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
216 ms |
2572 KB |
Output is correct |
2 |
Correct |
93 ms |
1792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
282 ms |
2796 KB |
Output is correct |
2 |
Correct |
166 ms |
2432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
186 ms |
2476 KB |
Output is correct |
2 |
Correct |
118 ms |
2304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
330 ms |
2744 KB |
Output is correct |
2 |
Correct |
241 ms |
2908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
216 ms |
2584 KB |
Output is correct |
2 |
Correct |
129 ms |
2552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
293 ms |
3224 KB |
Output is correct |
2 |
Correct |
262 ms |
3240 KB |
Output is correct |