답안 #501799

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
501799 2022-01-04T15:15:38 Z vrohak Cards (LMIO19_korteles) C++14
100 / 100
64 ms 12612 KB
#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]++;
        ad[l][k][m]++;
        bc[m][n][l]++;
        cd[n][l][k]++;
        abcd[k][l][m][n]++;
    }
    cout << sol;
    return 0;
}

Compilation message

korteles.cpp: In function 'int main()':
korteles.cpp:16:14: 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:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%s", cards[i][1]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 428 KB Output is correct
3 Correct 1 ms 684 KB Output is correct
4 Correct 1 ms 844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 428 KB Output is correct
3 Correct 1 ms 684 KB Output is correct
4 Correct 1 ms 844 KB Output is correct
5 Correct 0 ms 300 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 2124 KB Output is correct
10 Correct 3 ms 2636 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 12516 KB Output is correct
2 Correct 57 ms 12612 KB Output is correct
3 Correct 56 ms 12612 KB Output is correct
4 Correct 56 ms 12596 KB Output is correct
5 Correct 64 ms 12592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 8 ms 3896 KB Output is correct
3 Correct 39 ms 8972 KB Output is correct
4 Correct 23 ms 6680 KB Output is correct
5 Correct 22 ms 6648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 300 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 2124 KB Output is correct
6 Correct 3 ms 2636 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 428 KB Output is correct
10 Correct 1 ms 684 KB Output is correct
11 Correct 1 ms 844 KB Output is correct
12 Correct 57 ms 12516 KB Output is correct
13 Correct 57 ms 12612 KB Output is correct
14 Correct 56 ms 12612 KB Output is correct
15 Correct 56 ms 12596 KB Output is correct
16 Correct 64 ms 12592 KB Output is correct
17 Correct 8 ms 3896 KB Output is correct
18 Correct 39 ms 8972 KB Output is correct
19 Correct 23 ms 6680 KB Output is correct
20 Correct 22 ms 6648 KB Output is correct
21 Correct 16 ms 5040 KB Output is correct
22 Correct 52 ms 10448 KB Output is correct
23 Correct 31 ms 7764 KB Output is correct
24 Correct 31 ms 7852 KB Output is correct