Submission #1531344


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
long long a[405];
long long x[405][4];
long long c[405][10];
map<long long,int>m;
long long get(long long x,long long y,long long z,long long h){return (((((x<<10)+y)<<10)+z)<<10)+h;}
long long doit(long long x,long long y,long long z,long long h){return min(min(get(x,y,z,h),get(y,z,h,x)),min(get(z,h,x,y),get(h,x,y,z)));}
long long fac(long long x){long long ret=1;for(int i=1;i<=x;i++)ret*=i;return ret;}
long long rot(long long x)
{
    int k[4];
	for(int i=0;i<=3;i++,x>>=10)k[i]=x&((1<<10)-1);
    if(k[0]==k[1]&&k[1]==k[2]&&k[2]==k[3])return 4;
    if(k[0]==k[2]&&k[1]==k[3])return 2;
    return 1;
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)c[i][0]=c[i][i]=1;
    for(int i=1;i<=n;i++)for(int j=1;j<=min(4,i-1);j++)c[i][j]=c[i-1][j]+c[i-1][j-1];
    for(int i=1;i<=n;i++)
    {
    	for(int j=0;j<=3;j++)cin>>x[i][j];
    	a[i]=doit(x[i][0],x[i][1],x[i][2],x[i][3]);
    }
    long long ans=0;
    m.clear();
	for(int i=1;i<=n;i++)
	{
		for(int ii=1;ii<i;ii++)
		{
	        for(int j=0;j<=3;j++)
            {
                long long y[4];
            	y[0]=doit(x[ii][(j+1)%4],x[ii][(j+0)%4],x[i][1],x[i][0]);
                y[1]=doit(x[ii][(j+0)%4],x[ii][(j+3)%4],x[i][2],x[i][1]);
                y[2]=doit(x[ii][(j+3)%4],x[ii][(j+2)%4],x[i][3],x[i][2]);
                y[3]=doit(x[ii][(j+2)%4],x[ii][(j+1)%4],x[i][0],x[i][3]);
                sort(y,y+4);
                long long ret=1;
                for(int p=0;p<4;)
                {
                    int cnt=1;
                    for(int r=p+1;r<4&&y[r]==y[p];r++)cnt++;
                    int num=m[y[p]];
                    if(y[p]==a[ii])num--;
                    if(num<cnt){ret=0;break;}
                    ret*=c[num][cnt]*pow(rot(y[p]),cnt)*fac(cnt);
                    p+=cnt;
                }
                ans+=ret;
            }
        }
		m[a[i]]++;
    }
    cout<<ans<<endl;
    return 0;
}

Submission Info

Submission Time
Task E - Building Cubes with AtCoDeer
User xuyuan
Language C++14 (GCC 5.4.1)
Score 900
Code Size 2016 Byte
Status AC
Exec Time 112 ms
Memory 20224 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 39 ms 256 KB
1_004.txt AC 4 ms 256 KB
1_005.txt AC 36 ms 256 KB
1_006.txt AC 26 ms 256 KB
1_007.txt AC 50 ms 256 KB
1_008.txt AC 44 ms 256 KB
1_009.txt AC 57 ms 256 KB
1_010.txt AC 7 ms 256 KB
1_011.txt AC 40 ms 512 KB
1_012.txt AC 1 ms 256 KB
1_013.txt AC 110 ms 17920 KB
1_014.txt AC 2 ms 512 KB
1_015.txt AC 109 ms 20224 KB
1_016.txt AC 27 ms 5760 KB
1_017.txt AC 111 ms 20224 KB
1_018.txt AC 108 ms 20224 KB
1_019.txt AC 112 ms 19968 KB