#include <bits/stdc++.h>
// #pragma GCC target("popcnt")
using namespace std;
int const maxn = 50505;
int const maxm = 7;
bitset<maxn> cnt[maxm][30];
bitset<maxn> tmp, at;
int main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector<string> v(n);
for (int i = 0; i < n; i++) {
auto& s = v[i];
cin >> s;
for (int j = 0; j < m; j++) {
if (s[j] == '?')
for (int k = 0; k < 26; k++)
cnt[j][k][i] = true;
else
cnt[j][s[j] - 'a'][i] = true;
}
}
int64_t ans = 0;
for (int i = 0; i < n; i++) at[i] = true;
for (int j = 0; j < n; j++) {
auto const& s = v[j];
at[j] = false;
tmp = at;
for (int i = 0; i < m; i++) {
char c = s[i];
if (c == '?') continue;
tmp &= cnt[i][c-'a'];
}
ans += tmp.count();
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
186 ms |
2176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
120 ms |
1664 KB |
Output is correct |
2 |
Correct |
113 ms |
1664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
173 ms |
1920 KB |
Output is correct |
2 |
Correct |
190 ms |
2304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
150 ms |
1792 KB |
Output is correct |
2 |
Correct |
119 ms |
1792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
203 ms |
2432 KB |
Output is correct |
2 |
Correct |
99 ms |
1792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
273 ms |
2560 KB |
Output is correct |
2 |
Correct |
160 ms |
2304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
179 ms |
2304 KB |
Output is correct |
2 |
Correct |
113 ms |
2048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
256 ms |
2560 KB |
Output is correct |
2 |
Correct |
236 ms |
2688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
220 ms |
2304 KB |
Output is correct |
2 |
Correct |
147 ms |
2304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
293 ms |
2944 KB |
Output is correct |
2 |
Correct |
228 ms |
2944 KB |
Output is correct |