# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
462164 |
2021-08-10T08:24:29 Z |
AlexLuchianov |
PIN (CEOI10_pin) |
C++14 |
|
33 ms |
7628 KB |
#include <iostream>
#include <vector>
#include <algorithm>
using ll = long long;
int const sigma = 37;
int const nmax = sigma * sigma * sigma * sigma;
int frec[sigma][sigma][sigma][sigma];
ll dp[1 + 4];
int convert(char ch) {
if('0' <= ch && ch <= '9')
return ch - '0' + 1;
else
return ch - 'a' + 11;
}
int main() {
int n, target;
std::cin >> n >> target;
for(int i = 1;i <= n; i++) {
std::string s;
std::cin >> s;
int a = convert(s[0]), b = convert(s[1]), c = convert(s[2]), d = convert(s[3]);
for(int mask = 0; mask < (1 << 4); mask++) {
frec[a * (0 < (mask & (1 << 3)))][b * (0 < (mask & (1 << 2)))][c * (0 < (mask & (1 << 1)))][d * (0 < (mask & (1 << 0)))]++;
}
}
for(int a = 0; a < sigma; a++)
for(int b = 0; b < sigma; b++)
for(int c = 0; c < sigma; c++)
for(int d = 0; d < sigma; d++)
dp[(a == 0) + (b == 0) + (c == 0) + (d == 0)] += 1LL * frec[a][b][c][d] * (frec[a][b][c][d] - 1) / 2;
dp[2] -= dp[1] * 3;
dp[3] -= dp[1] * 3;
dp[3] -= dp[2] * 2;
dp[4] -= dp[1];
dp[4] -= dp[2];
dp[4] -= dp[3];
std::cout << dp[target];
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1740 KB |
Output is correct |
2 |
Correct |
8 ms |
1856 KB |
Output is correct |
3 |
Correct |
7 ms |
1828 KB |
Output is correct |
4 |
Correct |
13 ms |
1864 KB |
Output is correct |
5 |
Correct |
14 ms |
1868 KB |
Output is correct |
6 |
Correct |
17 ms |
1864 KB |
Output is correct |
7 |
Correct |
13 ms |
1860 KB |
Output is correct |
8 |
Correct |
16 ms |
1860 KB |
Output is correct |
9 |
Correct |
21 ms |
1868 KB |
Output is correct |
10 |
Correct |
22 ms |
1864 KB |
Output is correct |
11 |
Correct |
16 ms |
1872 KB |
Output is correct |
12 |
Correct |
24 ms |
1868 KB |
Output is correct |
13 |
Correct |
18 ms |
1868 KB |
Output is correct |
14 |
Correct |
18 ms |
1864 KB |
Output is correct |
15 |
Correct |
23 ms |
1864 KB |
Output is correct |
16 |
Correct |
23 ms |
7500 KB |
Output is correct |
17 |
Correct |
33 ms |
7620 KB |
Output is correct |
18 |
Correct |
33 ms |
7616 KB |
Output is correct |
19 |
Correct |
25 ms |
7628 KB |
Output is correct |
20 |
Correct |
29 ms |
7628 KB |
Output is correct |