Submission #501907

# Submission time Handle Problem Language Result Execution time Memory
501907 2022-01-04T19:01:09 Z vrohak Cards (LMIO19_korteles) C++14
100 / 100
71 ms 11876 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 5 * 1e5;

long long int a[27][27], b[27][27], c[27][27], d[27][27], ab[27][27][27],
    ad[27][27][27], bc[27][27][27], cd[27][27][27];
int abcd[27][27][27][27], ac[27][27][27], bd[27][27][27], x, y, z, w, n;
char cards[MAXN][4][4];
long long int sol = 0;

int main() {
   cin >> n;
   for (int i = 0; i < n; i++) {
      scanf("%s", cards[i][0]);
      scanf("%s", cards[i][1]);
   }
   for (int i = 0; i < n; i++) {
      x = cards[i][0][0] - 'A';
      y = cards[i][0][1] - 'A';
      z = cards[i][1][0] - 'A';
      w = cards[i][1][1] - 'A';

      sol += a[w][z] + b[y][w] + c[x][y] + d[z][x];
      sol -= abcd[w][z][x][y];
      sol -= abcd[x][y][w][z];

      if (y == z) {
         sol -= ab[w][z][w];
         sol -= cd[x][y][x];
      }

      if (x == w) {
         sol -= ad[z][x][z];
         sol -= bc[y][w][y];
      }

      if (y == z && w == x) sol += 3 * abcd[x][z][x][z];

      a[y][x]++;
      b[x][z]++;
      c[z][w]++;
      d[w][y]++;
      ab[y][x][z]++;
      ad[w][y][x]++;
      bc[x][z][w]++;
      cd[z][w][y]++;
      abcd[y][x][z][w]++;
   }
   cout << sol;
   return 0;
}

Compilation message

korteles.cpp: In function 'int main()':
korteles.cpp:16:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |       scanf("%s", cards[i][0]);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~
korteles.cpp:17:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |       scanf("%s", cards[i][1]);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 428 KB Output is correct
3 Correct 1 ms 680 KB Output is correct
4 Correct 1 ms 816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 428 KB Output is correct
3 Correct 1 ms 680 KB Output is correct
4 Correct 1 ms 816 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 1 ms 2252 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 2 ms 2892 KB Output is correct
9 Correct 2 ms 2252 KB Output is correct
10 Correct 2 ms 2616 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 11876 KB Output is correct
2 Correct 60 ms 11180 KB Output is correct
3 Correct 71 ms 11180 KB Output is correct
4 Correct 65 ms 11272 KB Output is correct
5 Correct 58 ms 11176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 8 ms 3916 KB Output is correct
3 Correct 41 ms 9156 KB Output is correct
4 Correct 25 ms 6560 KB Output is correct
5 Correct 32 ms 6576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 1 ms 2252 KB Output is correct
3 Correct 1 ms 972 KB Output is correct
4 Correct 2 ms 2892 KB Output is correct
5 Correct 2 ms 2252 KB Output is correct
6 Correct 2 ms 2616 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 296 KB Output is correct
9 Correct 0 ms 428 KB Output is correct
10 Correct 1 ms 680 KB Output is correct
11 Correct 1 ms 816 KB Output is correct
12 Correct 59 ms 11876 KB Output is correct
13 Correct 60 ms 11180 KB Output is correct
14 Correct 71 ms 11180 KB Output is correct
15 Correct 65 ms 11272 KB Output is correct
16 Correct 58 ms 11176 KB Output is correct
17 Correct 8 ms 3916 KB Output is correct
18 Correct 41 ms 9156 KB Output is correct
19 Correct 25 ms 6560 KB Output is correct
20 Correct 32 ms 6576 KB Output is correct
21 Correct 15 ms 4912 KB Output is correct
22 Correct 46 ms 9268 KB Output is correct
23 Correct 31 ms 6852 KB Output is correct
24 Correct 31 ms 6980 KB Output is correct