Submission #1531296
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
long long a[405];
long long x[405][4];
long long c[405][10];
long long dp[405][10];
int mp[4][4] = {{1,0,3,2},{0,3,2,1},{3,2,1,0},{2,1,0,3}};
map<long long,int>m;
long long get(long long x,long long y,long long z,long long h)
{
long long ret = x;
ret = (ret<<10)+y;
ret = (ret<<10)+z;
ret = (ret<<10)+h;
return ret;
}
long long pack(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;i++)cin>>x[i][j];
a[i] = pack(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;i<i;i++)
{
for(int j=0;j<=3;j++)
{
long long y[4];
y[0]=pack(x[ii][(j+1)%4],x[ii][(j+0)%4],x[i][1],x[i][0]);
y[1]=pack(x[ii][(j+0)%4],x[ii][(j+3)%4],x[i][2],x[i][1]);
y[2]=pack(x[ii][(j+3)%4],x[ii][(j+2)%4],x[i][3],x[i][2]);
y[3]=pack(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
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 900 |
Status |
|
|
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 |
TLE |
4203 ms |
256 KB |
0_001.txt |
TLE |
4203 ms |
256 KB |
0_002.txt |
TLE |
4203 ms |
256 KB |
1_003.txt |
RE |
95 ms |
256 KB |
1_004.txt |
TLE |
4203 ms |
256 KB |
1_005.txt |
RE |
95 ms |
256 KB |
1_006.txt |
RE |
95 ms |
256 KB |
1_007.txt |
RE |
96 ms |
256 KB |
1_008.txt |
RE |
95 ms |
256 KB |
1_009.txt |
RE |
96 ms |
256 KB |
1_010.txt |
TLE |
4203 ms |
256 KB |
1_011.txt |
RE |
96 ms |
256 KB |
1_012.txt |
TLE |
4203 ms |
256 KB |
1_013.txt |
RE |
95 ms |
256 KB |
1_014.txt |
TLE |
4203 ms |
256 KB |
1_015.txt |
RE |
96 ms |
256 KB |
1_016.txt |
RE |
95 ms |
256 KB |
1_017.txt |
RE |
95 ms |
256 KB |
1_018.txt |
RE |
96 ms |
256 KB |
1_019.txt |
RE |
95 ms |
256 KB |