# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
301050 | 2020-09-17T16:03:28 Z | evpipis | PIN (CEOI10_pin) | C++11 | 180 ms | 2944 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 51 ms | 792 KB | Output is correct |
5 | Correct | 60 ms | 768 KB | Output is correct |
6 | Correct | 60 ms | 888 KB | Output is correct |
7 | Correct | 49 ms | 796 KB | Output is correct |
8 | Correct | 66 ms | 768 KB | Output is correct |
9 | Correct | 106 ms | 896 KB | Output is correct |
10 | Correct | 123 ms | 928 KB | Output is correct |
11 | Correct | 65 ms | 888 KB | Output is correct |
12 | Correct | 115 ms | 896 KB | Output is correct |
13 | Correct | 72 ms | 888 KB | Output is correct |
14 | Correct | 65 ms | 768 KB | Output is correct |
15 | Correct | 116 ms | 1016 KB | Output is correct |
16 | Correct | 124 ms | 2420 KB | Output is correct |
17 | Correct | 175 ms | 2936 KB | Output is correct |
18 | Correct | 134 ms | 2560 KB | Output is correct |
19 | Correct | 161 ms | 2936 KB | Output is correct |
20 | Correct | 180 ms | 2944 KB | Output is correct |