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>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define int long long
using namespace std;
const int N = 2205;
map<vector<int>,int> cnt;
vector<int> cards[N];
signed main(){
fastio
int n,k;
cin >> n >> k;
for(int i = 0; i < n; i++){
for(int j = 0; j < k; j++){
char c;
cin >> c;
cards[i].push_back(c-'0'-1);
}
cnt[cards[i]]++;
}
int ans = 0;
for(int i = 0; i < n; i++){
cnt[cards[i]]--;
for(int j = i+1; j < n; j++){
cnt[cards[j]]--;
vector<int> need;
for(int x = 0; x < k; x++){
if(cards[i][x]==cards[j][x]){
need.push_back(cards[i][x]);
}else{
need.push_back(3-cards[i][x]-cards[j][x]);
}
}
ans += cnt[need];
}
for(int j = i+1; j < n; j++){
cnt[cards[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... |