# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
301050 | evpipis | PIN (CEOI10_pin) | C++11 | 180 ms | 2944 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;
#define fi first
#define se second
const int len = 5e4+5;
int out[len], n, k;
char str[len][5];
int solve(int bit){
map<string, int> mym;
for (int i = 0; i < n; i++){
string temp;
for (int j = 0; j < 4; j++){
if (bit&(1<<j)) temp.push_back('*');
else temp.push_back(str[i][j]);
}
mym[temp]++;
}
int ans = 0;
for (auto &it: mym)
ans += (it.se * 1LL * (it.se-1))/2; //, cout << it.fi << " " << it.se << endl;
//printf("solving bit = %d\n", bit);
//printf("ans = %d\n", ans);
return ans;
}
int main(){
scanf("%d %d", &n, &k);
for (int i = 0; i < n; i++)
scanf("%s", &str[i]);
int ans = 0;
for (int bit = 1; bit < (1<<4); bit++){
out[bit] = solve(bit);
for (int sub = 1; sub < bit; sub++)
if ((sub&bit) == sub)
out[bit] -= out[sub];
if (__builtin_popcount(bit) == k)
ans += out[bit];
}
printf("%d\n", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |