#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;
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;
int num = 0, len = 0;
string p;
for(int j = 0;j < m; j++){
if(s[j] != '?'){
p += s[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[k];
}
}
mp[j][p]++;
}
}
cout << sol << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
384 KB |
Output is correct |
2 |
Correct |
14 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
492 KB |
Output is correct |
2 |
Correct |
39 ms |
476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
1528 KB |
Output is correct |
2 |
Correct |
36 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
1272 KB |
Output is correct |
2 |
Correct |
90 ms |
2936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
568 ms |
11936 KB |
Output is correct |
2 |
Correct |
82 ms |
1400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1090 ms |
29496 KB |
Output is correct |
2 |
Correct |
125 ms |
2680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2071 ms |
55260 KB |
Output is correct |
2 |
Correct |
892 ms |
25080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1613 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 |
1528 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |