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;
#define ll long long
#define Foxyy cin.tie(0); cout.sync_with_stdio(0); cout.tie(0);
struct Solver {
int& n;
int& k;
vector<string>& cards;
void solve() {
map<string, int> cnt;
for (auto& card : cards) {
cnt[card]++;
}
ll ans = 0;
for (int i = 0; i < n-1; i++) {
for (int j = i+1; j < n; j++) {
string card(k, '$');
for (int pos = 0; pos < k; pos++) {
if (cards[i][pos] == cards[j][pos]) {
card[pos] = cards[i][pos];
} else {
card[pos] = 6 - (cards[i][pos] - '0') - (cards[j][pos] - '0') + '0';
}
}
// cerr << i << ' ' << j << ' ' << card << '\n';
ans += cnt[card];
}
}
cout << ans/3 << '\n';
}
};
signed main() {
Foxyy
int T = 1;
// cin >> T;
while(T--) {
int n, k;
cin >> n >> k;
vector<string> cards(n);
for (auto& card : cards) {
cin >> card;
}
Solver solver{n, k, cards};
solver.solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |