Submission #1688190


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 hash(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(hash(x,y,z,s),hash(y,z,s,x)),min(hash(z,s,x,y),hash(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 1859 Byte
Status CE

Compile Error

./Main.cpp: In function ‘ll trans(long long int, long long int, long long int, long long int)’:
./Main.cpp:31:17: error: reference to ‘hash’ is ambiguous
  return min(min(hash(x,y,z,s),hash(y,z,s,x)),min(hash(z,s,x,y),hash(s,x,y,z)));
                 ^
./Main.cpp:24:11: note: candidates are: ll hash(long long int, long long int, long long int, long long int)
 inline ll hash(int x,int y,int z,int s)
           ^
In file included from /usr/include/c++/5/bits/basic_string.h:5556:0,
                 from /usr/include/c++/5/string:52,
                 from /usr/include/c++/5/bits/locale_classes.h:40,
                 from /usr/include/c++/5/bits/ios_base.h:41,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 fr...