# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
501908 | 2022-01-04T19:03:45 Z | vrohak | Cards (LMIO19_korteles) | C++14 | 83 ms | 9732 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 588 KB | Output is correct |
4 | Correct | 1 ms | 716 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 588 KB | Output is correct |
4 | Correct | 1 ms | 716 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 1996 KB | Output is correct |
7 | Correct | 1 ms | 844 KB | Output is correct |
8 | Correct | 2 ms | 2636 KB | Output is correct |
9 | Correct | 1 ms | 1868 KB | Output is correct |
10 | Correct | 2 ms | 2380 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 83 ms | 9700 KB | Output is correct |
2 | Correct | 55 ms | 9732 KB | Output is correct |
3 | Correct | 55 ms | 9716 KB | Output is correct |
4 | Correct | 57 ms | 9672 KB | Output is correct |
5 | Correct | 55 ms | 9668 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 12 ms | 3404 KB | Output is correct |
3 | Correct | 43 ms | 7300 KB | Output is correct |
4 | Correct | 32 ms | 5340 KB | Output is correct |
5 | Correct | 22 ms | 5252 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 1996 KB | Output is correct |
3 | Correct | 1 ms | 844 KB | Output is correct |
4 | Correct | 2 ms | 2636 KB | Output is correct |
5 | Correct | 1 ms | 1868 KB | Output is correct |
6 | Correct | 2 ms | 2380 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 588 KB | Output is correct |
11 | Correct | 1 ms | 716 KB | Output is correct |
12 | Correct | 83 ms | 9700 KB | Output is correct |
13 | Correct | 55 ms | 9732 KB | Output is correct |
14 | Correct | 55 ms | 9716 KB | Output is correct |
15 | Correct | 57 ms | 9672 KB | Output is correct |
16 | Correct | 55 ms | 9668 KB | Output is correct |
17 | Correct | 12 ms | 3404 KB | Output is correct |
18 | Correct | 43 ms | 7300 KB | Output is correct |
19 | Correct | 32 ms | 5340 KB | Output is correct |
20 | Correct | 22 ms | 5252 KB | Output is correct |
21 | Correct | 13 ms | 4176 KB | Output is correct |
22 | Correct | 47 ms | 8088 KB | Output is correct |
23 | Correct | 28 ms | 6156 KB | Output is correct |
24 | Correct | 35 ms | 6128 KB | Output is correct |