Submission #598886

# Submission time Handle Problem Language Result Execution time Memory
598886 2022-07-19T07:11:18 Z MrDeboo Cards (LMIO19_korteles) C++17
100 / 100
455 ms 41040 KB
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int a[16][1000000];
int idk;
int git(char chr[2][2]){
    int b=0,g=1;
    for(int i=0;i<2;i++){
        for(int w=0;w<2;w++){
            b+=g*(chr[i][w]-'A');
            g*=27;
        }
    }
    return a[idk][b];
}
void incr(char chr[2][2]){
    int b=0,g=1;
    for(int i=0;i<2;i++){
        for(int w=0;w<2;w++){
            b+=g*(chr[i][w]-'A');
            g*=27;
        }
    }
    a[idk][b]++;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int ans=0;
    for(int i=0;i<n;i++){
        char chr[2][2];
        for(int w=0;w<2;w++){
            for(int j=0;j<2;j++){
                cin>>chr[w][j];
            }
        }
        for(int w=1;w<(1<<4);w++){
            char G[2][2];
            G[0][0]='Z'+1,G[1][0]='Z'+1,G[0][1]='Z'+1,G[1][1]='Z'+1;
            bool bl=1;
            for(int j=0;j<4;j++){
                if((1<<j)&w){
                    if(j==2){
                        if(G[1][0]!='Z'+1&&G[1][0]!=chr[0][0])bl=0;
                        if(G[1][1]!='Z'+1&&G[1][1]!=chr[0][1])bl=0;
                        G[1][0]=chr[0][0];
                        G[1][1]=chr[0][1];
                    }
                    if(j==3){
                        if(G[0][0]!='Z'+1&&G[0][0]!=chr[0][1])bl=0;
                        if(G[1][0]!='Z'+1&&G[1][0]!=chr[1][1])bl=0;
                        G[0][0]=chr[0][1];
                        G[1][0]=chr[1][1];
                    }
                    if(j==0){
                        if(G[0][0]!='Z'+1&&G[0][0]!=chr[1][0])bl=0;
                        if(G[0][1]!='Z'+1&&G[0][1]!=chr[1][1])bl=0;
                        G[0][0]=chr[1][0];
                        G[0][1]=chr[1][1];
                    }
                    if(j==1){
                        if(G[0][1]!='Z'+1&&G[0][1]!=chr[0][0])bl=0;
                        if(G[1][1]!='Z'+1&&G[1][1]!=chr[1][0])bl=0;
                        G[0][1]=chr[0][0];
                        G[1][1]=chr[1][0];
                    }
                }
            }
            if(!bl)continue;
            idk=w-1;
            ans+=git(G)*(__builtin_popcount(w)%2?1:-1);
        }
        for(int w=1;w<(1<<4);w++){
            char G[2][2];
            G[0][0]='Z'+1,G[1][0]='Z'+1,G[0][1]='Z'+1,G[1][1]='Z'+1;
            for(int j=0;j<4;j++){
                if((1<<j)&w){
                    if(j==0){
                        G[0][0]=chr[0][0];
                        G[0][1]=chr[0][1];
                    }
                    if(j==1){
                        G[0][1]=chr[0][1];
                        G[1][1]=chr[1][1];
                    }
                    if(j==2){
                        G[1][0]=chr[1][0];
                        G[1][1]=chr[1][1];
                    }
                    if(j==3){
                        G[0][0]=chr[0][0];
                        G[1][0]=chr[1][0];
                    }
                }
            }
            idk=w-1;
            incr(G);
        }
        // cout<<ans<<endl;
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 1 ms 1620 KB Output is correct
3 Correct 1 ms 2004 KB Output is correct
4 Correct 1 ms 2900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 1 ms 1620 KB Output is correct
3 Correct 1 ms 2004 KB Output is correct
4 Correct 1 ms 2900 KB Output is correct
5 Correct 0 ms 596 KB Output is correct
6 Correct 9 ms 18328 KB Output is correct
7 Correct 4 ms 6740 KB Output is correct
8 Correct 18 ms 35416 KB Output is correct
9 Correct 9 ms 17444 KB Output is correct
10 Correct 18 ms 25800 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 416 ms 38488 KB Output is correct
2 Correct 455 ms 41040 KB Output is correct
3 Correct 440 ms 40912 KB Output is correct
4 Correct 411 ms 41036 KB Output is correct
5 Correct 422 ms 40916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 58 ms 37452 KB Output is correct
3 Correct 279 ms 37556 KB Output is correct
4 Correct 172 ms 38476 KB Output is correct
5 Correct 171 ms 38556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 9 ms 18328 KB Output is correct
3 Correct 4 ms 6740 KB Output is correct
4 Correct 18 ms 35416 KB Output is correct
5 Correct 9 ms 17444 KB Output is correct
6 Correct 18 ms 25800 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 1 ms 1620 KB Output is correct
10 Correct 1 ms 2004 KB Output is correct
11 Correct 1 ms 2900 KB Output is correct
12 Correct 416 ms 38488 KB Output is correct
13 Correct 455 ms 41040 KB Output is correct
14 Correct 440 ms 40912 KB Output is correct
15 Correct 411 ms 41036 KB Output is correct
16 Correct 422 ms 40916 KB Output is correct
17 Correct 58 ms 37452 KB Output is correct
18 Correct 279 ms 37556 KB Output is correct
19 Correct 172 ms 38476 KB Output is correct
20 Correct 171 ms 38556 KB Output is correct
21 Correct 111 ms 38824 KB Output is correct
22 Correct 326 ms 40516 KB Output is correct
23 Correct 218 ms 39676 KB Output is correct
24 Correct 268 ms 39632 KB Output is correct