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>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
ll cnt[1<<25];
int a[600005],n,k;
int Xor(int a,int b){
int res=0;
for(int i=0;i<k;i++){
int f=(a>>(i*2))&3,s=(b>>(i*2))&3;
res+=((12-(f+s))%3)<<(2*i);
}
return res;
}
int convert(string s){
int res=0;
for(int i=0;i<k;i++){
res+=(s[i]-'1')<<(2*i);
}
return res;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>k;
ll res=0;
for(int i=0;i<n;i++){
string s;
cin>>s;
a[i]=convert(s);
res+=cnt[a[i]];
for(int j=0;j<i;j++)cnt[Xor(a[i],a[j])]++;
}
cout<<res;
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... |