Submission #462158

# Submission time Handle Problem Language Result Execution time Memory
462158 2021-08-10T08:20:20 Z AlexLuchianov PIN (CEOI10_pin) C++14
30 / 100
27 ms 7864 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;
  
  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
1 Correct 8 ms 1868 KB Output is correct
2 Incorrect 8 ms 1868 KB Output isn't correct
3 Incorrect 7 ms 1844 KB Output isn't correct
4 Correct 13 ms 1968 KB Output is correct
5 Correct 14 ms 1992 KB Output is correct
6 Incorrect 15 ms 1972 KB Output isn't correct
7 Incorrect 15 ms 1968 KB Output isn't correct
8 Correct 16 ms 1996 KB Output is correct
9 Correct 21 ms 2088 KB Output is correct
10 Incorrect 22 ms 2112 KB Output isn't correct
11 Incorrect 15 ms 2000 KB Output isn't correct
12 Incorrect 21 ms 2092 KB Output isn't correct
13 Incorrect 16 ms 2012 KB Output isn't correct
14 Incorrect 17 ms 2004 KB Output isn't correct
15 Incorrect 25 ms 1996 KB Output isn't correct
16 Correct 21 ms 7784 KB Output is correct
17 Incorrect 27 ms 7860 KB Output isn't correct
18 Incorrect 25 ms 7864 KB Output isn't correct
19 Incorrect 26 ms 7844 KB Output isn't correct
20 Incorrect 27 ms 7860 KB Output isn't correct