Submission #1686359


Source Code Expand

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>

using namespace std;

unordered_map<LL,LL> colorCount;

LL tolong(LL c0,LL c1,LL c2,LL c3){
    return (c0*1000000000LL+ c1*1000000LL +c2*1000LL +c3);
}

void toc(LL num,LL &c0, LL &c1,LL &c2,LL &c3){
    c0 = num/1000000000LL;
    num %= 1000000000LL;
    c1 = num/1000000LL;
    num%= 1000000LL;
    c2 = num/1000LL;
    num%=1000LL;
    c3 = num;
}

void add(LL c0,LL c1,LL c2,LL c3){
    colorCount[tolong(c0,c1,c2,c3)]+=1;
    colorCount[tolong(c3,c0,c1,c2)]+=1;
    colorCount[tolong(c2,c3,c0,c1)]+=1;
    colorCount[tolong(c1,c2,c3,c0)]+=1;
}

void sub(LL c0,LL c1,LL c2,LL c3){
    colorCount[tolong(c0,c1,c2,c3)]-=1;
    colorCount[tolong(c3,c0,c1,c2)]-=1;
    colorCount[tolong(c2,c3,c0,c1)]-=1;
    colorCount[tolong(c1,c2,c3,c0)]-=1;
}

int main(){

    int N;cin>>N;
    LL color[N];
    REP(i,N){
        LL c0,c1,c2,c3;
        cin>>c0>>c1>>c2>>c3;
        add(c0,c1,c2,c3);
        color[i]=tolong(c0,c1,c2,c3);
    }


    LL col[4];
    LL a,b,c,d,e,f,g,h;
    LL ans = 0;
    REP(i,N){
        toc(color[i],col[0],col[1],col[2],col[3]);
        sub(col[0],col[1],col[2],col[3]);
        a = col[0],b=col[1],c=col[2],d=col[3];
        REP(j,N){
            if(i==j)continue;
            toc(color[j],col[0],col[1],col[2],col[3]);
            sub(col[0],col[1],col[2],col[3]);
            REP(k,4){
                LL T = 1;
                e = col[(k)%4],h = col[(k+1)%4],g =col[(k+2)%4],f = col[(k+3)%4];
                T *= colorCount[tolong(e,f,b,a)];
                sub(e,f,b,a);
                T *= colorCount[tolong(f,g,c,b)];
                sub(f,g,c,b);
                T*= colorCount[tolong(g,h,d,c)];
                sub(g,h,d,c);
                T *= colorCount[tolong(h,e,a,d)];
                sub(h,e,a,d);

                ans += T;
                add(e,f,b,a);
                add(f,g,c,b);
                add(g,h,d,c);
                add(h,e,a,d);
            }
            add(col[0],col[1],col[2],col[3]);
        }
        toc(color[i],col[0],col[1],col[2],col[3]);
        add(col[0],col[1],col[2],col[3]);
    }

    cout<<ans/6<<endl;



    return 0;
}

Submission Info

Submission Time
Task E - Building Cubes with AtCoDeer
User inmir
Language C++14 (GCC 5.4.1)
Score 900
Code Size 2371 Byte
Status AC
Exec Time 3193 ms
Memory 239448 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 900 / 900
Status
AC × 3
AC × 20
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt
Case Name Status Exec Time Memory
0_000.txt AC 1 ms 256 KB
0_001.txt AC 1 ms 256 KB
0_002.txt AC 1 ms 256 KB
1_003.txt AC 316 ms 256 KB
1_004.txt AC 24 ms 256 KB
1_005.txt AC 319 ms 256 KB
1_006.txt AC 228 ms 256 KB
1_007.txt AC 426 ms 256 KB
1_008.txt AC 376 ms 256 KB
1_009.txt AC 374 ms 256 KB
1_010.txt AC 56 ms 256 KB
1_011.txt AC 387 ms 640 KB
1_012.txt AC 4 ms 512 KB
1_013.txt AC 2988 ms 239448 KB
1_014.txt AC 13 ms 2316 KB
1_015.txt AC 3185 ms 239448 KB
1_016.txt AC 630 ms 60880 KB
1_017.txt AC 3192 ms 239448 KB
1_018.txt AC 3186 ms 239448 KB
1_019.txt AC 3193 ms 239448 KB