# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
462158 | AlexLuchianov | PIN (CEOI10_pin) | C++14 | 27 ms | 7864 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 <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;
for(int i = 1; i <= target; i++)
for(int j = 1; j < i; j++)
dp[i] -= dp[j];
std::cout << dp[target];
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |