# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
742616 | ducanh1234 | PIN (CEOI10_pin) | C++14 | 296 ms | 14812 KiB |
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;
typedef long long ll;
const int K = 4;
const int N = 5e4+1;
map<string, ll> mp[(1<<K)];
ll ans[6], n, d;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>d;
for (int i=1; i<=n; ++i) {
string s; cin>>s;
for (int j=0; j<(1<<K); ++j) {
string tmp="";
for (int x=0; x<K; ++x) {
if (j&(1<<x)) tmp+=s[x];
}
++mp[j][tmp];
}
}
for (int m=0; m<(1<<K); ++m) {
ll tmp=0;
for (auto u : mp[m]) tmp+=u.second*(u.second-1)/2;
ans[4-__builtin_popcount(m)]+=tmp;
}
ll k;
if (d == 1) k=ans[1]-ans[0];
else if (d == 2) k=ans[2]-3*(ans[1]-ans[0]);
else if (d == 3) k=ans[3]-2*ans[2]+3*(ans[1]-ans[0]);
else k=ans[4]-ans[3]+ans[2]-ans[1]+ans[0];
k=max(0ll, k);
cout<<k<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |