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);
using namespace std;
const int N = 2205;
vector<int> cards[N];
int cnt[N];
int encode(vector<int> v){
int num = 0, now = 1;
for(auto x : v){
num += x*now;
now *= 3;
}
return num;
}
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[encode(cards[i])]++;
}
int ans = 0;
for(int i = 0; i < n; i++){
cnt[encode(cards[i])]--;
for(int j = i+1; j < n; j++){
cnt[encode(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[encode(need)];
}
for(int j = i+1; j < n; j++){
cnt[encode(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... |