Submission #1688194


Source Code Expand

#include <bits/stdc++.h>
#define N 500
#define int long long
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int c[N][4],n,C[N][6],fac[5];
ll A[N],Ans;
map <ll,int> M;
inline int fnd(long long y)
{
	int x[4]; 
	for(int i=0;i<4;i++) x[i]=y&((1<<10)-1),y>>=10;
	if(x[0]==x[1]&&x[1]==x[2]&&x[2]==x[3]) return 4;
	if(x[0]==x[2]&&x[1]==x[3]) return 2;
	return 1;
}
inline ll hsh(int x,int y,int z,int s)
{
	ll xs=(1ll*x<<30)+(1ll*y<<20)+(1ll*z<<10)+s;
	return xs;
}
inline ll trans(int x,int y,int z,int s)
{
	return min(min(hsh(x,y,z,s),hsh(y,z,s,x)),min(hsh(z,s,x,y),hsh(s,x,y,z)));
}
signed main()
{
	n=read(); for(int i=1;i<=n;i++)
	{
		for(int j=0;j<4;j++) c[i][j]=read();
		A[i]=trans(c[i][0],c[i][1],c[i][2],c[i][3]);
	}
	fac[0]=1; fac[1]=1; fac[2]=2; fac[3]=6; fac[4]=24;
	C[0][0]=1; for(int i=1;i<=n;i++)
	{
		C[i][0]=1;for(int j=1;j<=4;j++)
			C[i][j]=C[i-1][j-1]+C[i-1][j];
	} 
	for(int i=1;i<=n;i++) 
	{
		for(int j=1;j<i;j++)
		{
			for(int k=0;k<4;k++)
			{
				int y[4];
				y[0]=trans(c[i][(k+1)%4],c[i][(k+0)%4],c[j][1],c[j][0]);
				y[1]=trans(c[i][(k+0)%4],c[i][(k+3)%4],c[j][2],c[j][1]);
				y[2]=trans(c[i][(k+3)%4],c[i][(k+2)%4],c[j][3],c[j][2]);
				y[3]=trans(c[i][(k+2)%4],c[i][(k+1)%4],c[j][0],c[j][3]);
				sort(y,y+4); ll ret=1;
				for(int p=0;p<4;p++)
				{
					int s=p; while(y[s]==y[p]) s++;
					int tot=M[y[p]];
					if(A[j]==y[p]) tot--;
					if(s-p>tot) ret=0;
					for(int t=1;t<=s-p;t++) ret*=fnd(y[p]); 
					ret*=C[tot][s-p]*fac[s-p];
					p=s-1;
				}
				Ans+=ret;
			}
		}
		M[A[i]]++;
		//cout << A[i] << " " << M[A[i]] << endl;
	}
	cout << Ans << endl;
	return 0;
}

Submission Info

Submission Time
Task E - Building Cubes with AtCoDeer
User wcz111
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1854 Byte
Status WA
Exec Time 902 ms
Memory 80128 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 900
Status
AC × 2
WA × 1
AC × 13
WA × 7
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 WA 1 ms 256 KB
1_003.txt WA 26 ms 256 KB
1_004.txt WA 3 ms 256 KB
1_005.txt WA 25 ms 256 KB
1_006.txt WA 19 ms 256 KB
1_007.txt WA 43 ms 256 KB
1_008.txt WA 39 ms 384 KB
1_009.txt AC 70 ms 256 KB
1_010.txt AC 12 ms 256 KB
1_011.txt AC 105 ms 384 KB
1_012.txt AC 2 ms 384 KB
1_013.txt AC 809 ms 68352 KB
1_014.txt AC 4 ms 1024 KB
1_015.txt AC 778 ms 80000 KB
1_016.txt AC 128 ms 22272 KB
1_017.txt AC 889 ms 80128 KB
1_018.txt AC 886 ms 80000 KB
1_019.txt AC 902 ms 78976 KB