Submission #636153

# Submission time Handle Problem Language Result Execution time Memory
636153 2022-08-28T11:31:33 Z KarolZ Cards (LMIO19_korteles) C++14
100 / 100
75 ms 5836 KB
#include<iostream>
using namespace std;
int ab[30][30]; //gora
int cd[30][30]; //dol
int ac[30][30]; //lewo
int bd[30][30]; //prawo

int abc[30][30][30]; //gora lewo
int abd[30][30][30]; //gora prawo
int acd[30][30][30]; //dol lewo
int bcd[30][30][30]; //dol prawo

int abcd[30][30][30][30];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
    int n,sum=0,v1,v2,v3,v4;
    string s1,s2;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s1>>s2;
        v1=s1[0]-'A';
        v2=s1[1]-'A';
        v3=s2[0]-'A';
        v4=s2[1]-'A';
        //cout<<sum<<' ';
        sum+=ab[v3][v4];
        //cout<<sum<<' ';
        sum+=cd[v1][v2];
        //cout<<sum<<' ';
        sum+=ac[v2][v4];
        //cout<<sum<<' ';
        sum+=bd[v1][v3];
        //cout<<sum<<' ';
        sum-=abcd[v3][v4][v1][v2];
        //cout<<sum<<' ';
        if(v2==v3)sum-=abc[v2][v4][v4];
        //cout<<sum<<' ';
        if(v1==v4)sum-=abd[v3][v1][v3];
        //cout<<sum<<' ';
        if(v1==v4)sum-=acd[v2][v1][v2];
        //cout<<sum<<' ';
        if(v2==v3)sum-=bcd[v1][v1][v3];
        //cout<<sum<<' ';
        sum-=abcd[v2][v1][v4][v3];
        //cout<<sum<<' ';
        if(v1==v4&&v2==v3)sum+=abcd[v2][v1][v1][v2]*2;
        //cout<<sum<<' ';
        if(v1==v4&&v2==v3)sum+=abcd[v2][v1][v1][v2];
        //cout<<sum<<'\n';
        abcd[v1][v2][v3][v4]=1;
        ab[v1][v2]++;
        cd[v3][v4]++;
        ac[v1][v3]++;
        bd[v2][v4]++;
        abc[v1][v2][v3]++;
        abd[v1][v2][v4]++;
        acd[v1][v3][v4]++;
        bcd[v2][v3][v4]++;
    }
    cout<<sum;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 852 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 2 ms 2132 KB Output is correct
7 Correct 1 ms 872 KB Output is correct
8 Correct 4 ms 3028 KB Output is correct
9 Correct 2 ms 2004 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 3188 KB Output is correct
2 Correct 60 ms 5728 KB Output is correct
3 Correct 57 ms 5836 KB Output is correct
4 Correct 63 ms 5728 KB Output is correct
5 Correct 75 ms 5724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 8 ms 3180 KB Output is correct
3 Correct 38 ms 3160 KB Output is correct
4 Correct 22 ms 3156 KB Output is correct
5 Correct 26 ms 3156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 2 ms 2132 KB Output is correct
3 Correct 1 ms 872 KB Output is correct
4 Correct 4 ms 3028 KB Output is correct
5 Correct 2 ms 2004 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 724 KB Output is correct
11 Correct 1 ms 852 KB Output is correct
12 Correct 59 ms 3188 KB Output is correct
13 Correct 60 ms 5728 KB Output is correct
14 Correct 57 ms 5836 KB Output is correct
15 Correct 63 ms 5728 KB Output is correct
16 Correct 75 ms 5724 KB Output is correct
17 Correct 8 ms 3180 KB Output is correct
18 Correct 38 ms 3160 KB Output is correct
19 Correct 22 ms 3156 KB Output is correct
20 Correct 26 ms 3156 KB Output is correct
21 Correct 15 ms 3668 KB Output is correct
22 Correct 49 ms 5220 KB Output is correct
23 Correct 33 ms 4460 KB Output is correct
24 Correct 33 ms 4452 KB Output is correct