#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
const int MAX = 1e5 + 10, MAXOFF = 8;
int n, m;
ll sol;
string s[MAX];
map<string, ll> mp[1 << MAXOFF];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
cin >> n >> m;
for(int i = 0;i < n; i++){
cin >> s[i];
}
for(int i = 0;i < n; i++){
int num = 0, len = 0;
string p;
for(int j = 0;j < m; j++){
if(s[i][j] != '?'){
p += s[i][j];
num += (1 << j);
len++;
}
}
for(int j = 0;j < (1 << len); j++){
string tmp = p;
for(int k = 0;k < len; k++){
if((1 << k) & j) tmp[k] = '?';
}
sol += mp[num][tmp];
}
for(int j = 0;j < (1 << m); j++){
p = "";
for(int k = 0;k < m; k++){
if(j & (1 << k)){
p += s[i][k];
}
}
mp[j][p]++;
}
}
cout << sol << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
3448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
3584 KB |
Output is correct |
2 |
Correct |
17 ms |
3576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
3576 KB |
Output is correct |
2 |
Correct |
34 ms |
3576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
4628 KB |
Output is correct |
2 |
Correct |
36 ms |
3904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
4384 KB |
Output is correct |
2 |
Correct |
88 ms |
6076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
462 ms |
15064 KB |
Output is correct |
2 |
Correct |
80 ms |
4476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
821 ms |
32564 KB |
Output is correct |
2 |
Correct |
128 ms |
5756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1583 ms |
58252 KB |
Output is correct |
2 |
Correct |
679 ms |
28116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1214 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1100 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |