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>
using namespace std;
string op (string a, string b) {
string ret;
for (int i = 0; i < (int)a.length(); i++) {
if (a[i] == b[i]) ret += a[i];
else {
set <char> x = {'1', '2', '3'};
x.erase(a[i]); x.erase(b[i]);
ret += *(x.begin());
}
}
return ret;
}
string op2[2188][2188];
int main () {
int n, m;
cin >> n >> m;
string arr[n];
for (int i = 0; i < n; i++) cin >> arr[i];
for (int i = 0; i < n; i++) {
for (int j = 0; j < i; j++) {
op2[i][j] = op(arr[i], arr[j]);
}
}
long long ans = 0;
for (int i = 0; i < n; i++) {
unordered_map <string, int> freq2;
for (int j = 0; j < i; j++) {
if (arr[i] == arr[j]) continue;
ans += freq2[op2[i][j]];
freq2[arr[j]]++;
}
ans += freq2[arr[i]] * (freq2[arr[i]] - 1) / 2;
}
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... |