# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
301049 | 2020-09-17T16:02:07 Z | evpipis | PIN (CEOI10_pin) | C++11 | 184 ms | 3320 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 * (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 | 49 ms | 888 KB | Output is correct |
5 | Correct | 61 ms | 896 KB | Output is correct |
6 | Correct | 61 ms | 944 KB | Output is correct |
7 | Correct | 51 ms | 896 KB | Output is correct |
8 | Correct | 68 ms | 1016 KB | Output is correct |
9 | Correct | 110 ms | 1128 KB | Output is correct |
10 | Correct | 120 ms | 1276 KB | Output is correct |
11 | Correct | 67 ms | 896 KB | Output is correct |
12 | Correct | 114 ms | 1160 KB | Output is correct |
13 | Correct | 72 ms | 896 KB | Output is correct |
14 | Correct | 67 ms | 1016 KB | Output is correct |
15 | Incorrect | 116 ms | 1156 KB | Output isn't correct |
16 | Correct | 122 ms | 2560 KB | Output is correct |
17 | Correct | 184 ms | 3320 KB | Output is correct |
18 | Correct | 139 ms | 2808 KB | Output is correct |
19 | Correct | 160 ms | 3192 KB | Output is correct |
20 | Incorrect | 183 ms | 3280 KB | Output isn't correct |