# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
501799 | vrohak | Cards (LMIO19_korteles) | C++14 | 64 ms | 12612 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;
long long int x, 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], k, l, m, n;
int abcd[27][27][27][27], ac[27][27][27], bd[27][27][27];
char cards[MAXN][4][4];
long long int sol=0;
int main()
{
cin >> x;
for(int i=0;i<x;i++){
scanf("%s", cards[i][0]);
scanf("%s", cards[i][1]);
}
for(int i=x-1;i>=0;i--){
k = cards[i][0][0]-'A';
l = cards[i][0][1]-'A';
m = cards[i][1][0]-'A';
n = cards[i][1][1]-'A';
sol+=c[k][m]+d[m][n]+a[l][n]+b[k][l]-(n==k?ab[l][n][l]:0)-(l==m?(ad[n][l][n]+bc[k][l][k]):0)-(k==n?cd[m][k][m]:0)+((k == n && l == m)?abcd[l][k][n][m]:-abcd[m][n][k][l]-abcd[l][k][n][m]);
//cout << ab[l][n][l] << ' ' << ad[n][l][n] << ' ' << bc[k][l][k] << ' ' << cd[m][k][m] << endl;
a[k][m]++;
b[m][n]++;
c[l][n]++;
d[k][l]++;
ab[k][m][n]++;
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... |