| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 501908 | vrohak | Cards (LMIO19_korteles) | C++14 | 83 ms | 9732 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 <bits/stdc++.h>
using namespace std;
const int MAXN = 5 * 1e5;
int a[27][27], b[27][27], c[27][27], d[27][27];
int 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];
int x, y, z, w, n;
char cards[MAXN][4][4];
long long int sol = 0;
int main() {
   scanf("%d", &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]++;
   }
   printf("%lld", sol);
   return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
