This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |