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;
int add[2200][2200];
void PlayGround() {
int n, k; cin >> n >> k;
vector <int> v(n);
vector <string> str(n);
map<int,int>have;
for(int i=0; i<n; ++i) {
string s; cin >> s;
str[i] = s;
int num = 0;
for(int j=0; j<k; ++j) {
int d = s[j]-'0';
if(d&1) num += 1<<(j*2);
if(d&2) num += 1<<(j*2+1);
}
v[i] = num;
have[num] = 1;
}
for(int i=0; i<n; ++i) {
for(int j=0; j<n; ++j) {
int more = 0;
for(int id=0; id<k; ++id) if(str[i][id]==str[j][id]) {
int d = str[i][id]-'0';
if(d&1) more += 1<<(id*2);
if(d&2) more += 1<<(id*2+1);
}
add[i][j] = more;
}
}
long long ans = 0;
for(int i=0; i<n; ++i) {
for(int j=0; j<n; ++j) if(i!=j) {
int req = (v[i]^v[j]) + add[i][j];
if(have.count(req)) ++ans;
}
}
ans /= 6;
cout << ans << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
PlayGround();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |