# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
238957 |
2020-06-13T18:49:09 Z |
dolphingarlic |
PIN (CEOI10_pin) |
C++14 |
|
314 ms |
14584 KB |
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
map<string, ll> cnt[16];
ll ans[5];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n, d;
cin >> n >> d;
FOR(i, 0, n) {
string s;
cin >> s;
FOR(j, 0, 16) {
string sub = "";
FOR(k, 0, 4) if (j & (1 << k)) sub += s[k];
cnt[j][sub]++;
}
}
FOR(i, 0, 16) {
ll contrib = 0;
for (pair<string, ll> j : cnt[i])
contrib += j.second * (j.second - 1) / 2;
ans[4 - __builtin_popcount(i)] += contrib;
}
if (d == 1) cout << ans[1] - ans[0];
else if (d == 2) cout << ans[2] - 3 * (ans[1] - ans[0]);
else if (d == 3) cout << ans[3] - 2 * ans[2] + 3 * (ans[1] - ans[0]);
else cout << ans[4] - ans[3] + ans[2] - ans[1] + ans[0];
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
1024 KB |
Output is correct |
2 |
Correct |
10 ms |
1024 KB |
Output is correct |
3 |
Correct |
9 ms |
896 KB |
Output is correct |
4 |
Correct |
68 ms |
3320 KB |
Output is correct |
5 |
Correct |
113 ms |
3704 KB |
Output is correct |
6 |
Correct |
106 ms |
3708 KB |
Output is correct |
7 |
Correct |
81 ms |
3272 KB |
Output is correct |
8 |
Correct |
94 ms |
3960 KB |
Output is correct |
9 |
Correct |
162 ms |
5240 KB |
Output is correct |
10 |
Correct |
166 ms |
5604 KB |
Output is correct |
11 |
Correct |
91 ms |
3836 KB |
Output is correct |
12 |
Correct |
177 ms |
5432 KB |
Output is correct |
13 |
Correct |
116 ms |
4088 KB |
Output is correct |
14 |
Correct |
99 ms |
3940 KB |
Output is correct |
15 |
Correct |
178 ms |
5368 KB |
Output is correct |
16 |
Correct |
195 ms |
11128 KB |
Output is correct |
17 |
Correct |
306 ms |
14584 KB |
Output is correct |
18 |
Correct |
237 ms |
12184 KB |
Output is correct |
19 |
Correct |
276 ms |
13432 KB |
Output is correct |
20 |
Correct |
314 ms |
14584 KB |
Output is correct |