#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define inf 1e18+1e9
#define F first
#define S second
#define int long long
#define mod (int)(1e9+7)
#define maxn 1000100
#define pii pair<int,int>
#define mod2 998244353
const int maxtime=1e8;
const long double eps=1e-9;
ld dist(ld x1,ld y1,ld x2,ld y2) {
return sqrt(abs(x1-x2)*abs(x1-x2)+abs(y1-y2)*abs(y1-y2));
}
int n,d;
string s[50500];
int b[10];
int ans[20];
void solve () {
cin>>n>>d;
for (int i=1;i<=n;i++) {
cin>>s[i];
}
int m=4;
for (int mask=0;mask<16;mask++) {
map<string,int>mp;
for (int i=0;i<n;i++) {
string t="";
for (int j=0;j<m;j++) {
if (mask&(1<<j)) {
t+=s[i][j];
}
}
ans[mask]+=mp[t];
mp[t]++;
}
}
cout<<(ans[1]+ans[2]+ans[4]+ans[8])-ans[15];;
}/*
0->
1->1
2->2
3->1 2
4->3
5->1 3
6->2 3
7->1 2 3
8->4
9->1 4
10->2 4
11->1 2 4
12->3 4
13->1 3 4
14->2 3 4
15->1 2 3 4
*/
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int t=1;
// cin>>t;
for (int ii=1;ii<=t;ii++) {
solve();
// asd();
if (ii<t)cout<<"\n";
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |