#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define taskname "Parametriziran"
using namespace std;
typedef long long ll;
typedef pair <int, int> ii;
const int N = 50000;
const int M = 6;
int n, m;
bitset <N> bs[M][26], cur;
void readInput(){
cin >> n >> m;
}
void solve(){
ll res = 0;
for(int i = 0; i < n; i++){
string s;
cin >> s;
bitset <N> tmp = cur;
for(int j = 0; j < m; j++){
if (s[j] == '?')
continue;
tmp &= bs[j][s[j] - 'a'];
}
res += tmp.count();
for(int j = 0; j < m; j++)
if (s[j] == '?')
for(int c = 0; c < 26; c++)
bs[j][c][i] = 1;
else
bs[j][s[j] - 'a'][i] = 1;
cur[i] = 1;
}
cout << res;
}
int main(){
//freopen(taskname".inp", "r", stdin);
//freopen(taskname".out", "w", stdout);
readInput();
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
159 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
632 KB |
Output is correct |
2 |
Correct |
102 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
146 ms |
780 KB |
Output is correct |
2 |
Correct |
183 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
119 ms |
760 KB |
Output is correct |
2 |
Correct |
116 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
191 ms |
888 KB |
Output is correct |
2 |
Correct |
96 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
240 ms |
888 KB |
Output is correct |
2 |
Correct |
150 ms |
1008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
179 ms |
1272 KB |
Output is correct |
2 |
Correct |
112 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
224 ms |
1400 KB |
Output is correct |
2 |
Correct |
198 ms |
1400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
192 ms |
1528 KB |
Output is correct |
2 |
Correct |
120 ms |
1528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
279 ms |
1784 KB |
Output is correct |
2 |
Correct |
225 ms |
1660 KB |
Output is correct |