#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("popcnt")
using namespace std;
int k;
struct Word {
unsigned v[6];
Word() = default;
Word& operator=(string const& s) {
for (int i = 0; i < k; i++) {
if (s[i] == '?') v[i] = 0;
else v[i] = 1u<<(s[i]-'a');
}
return *this;
}
inline bool ok(Word const& rhs) const {
for (int i = 0; i < k; i++) {
if (__builtin_popcount(v[i]^rhs.v[i]) == 2)
return false;
}
return true;
}
};
int const maxn = 50505;
Word v[maxn];
int main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
int n;
cin >> n >> k;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
v[i] = s;
}
int ans = 0;
for (int i = 0; i < n; i++) {
for (int j = i+1; j < n; j++)
ans += v[i].ok(v[j]);
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1923 ms |
1784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1538 ms |
1156 KB |
Output is correct |
2 |
Correct |
2731 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3020 ms |
1280 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1584 ms |
1188 KB |
Output is correct |
2 |
Execution timed out |
3027 ms |
1152 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3027 ms |
1664 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3030 ms |
1664 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3009 ms |
1408 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2412 ms |
1664 KB |
Output is correct |
2 |
Execution timed out |
3023 ms |
1664 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1885 ms |
1408 KB |
Output is correct |
2 |
Correct |
2874 ms |
1372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3080 ms |
1840 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |