Submission #1676264
Source Code Expand
#include<bits/stdc++.h>
#define N 1005
#define LL long long
#define PAIR pair<LL,int>
using namespace std;
const int mo=1e6+7;
vector<PAIR> G[mo];
int n,c[N][4],f[4];
PAIR z[4]; LL now,ans;
LL H(int g[4],int x)
{
int i; LL S=0;
for(i=0;i<4;i++)
S=S*1000+g[(i+x)&3];
return S;
}
LL Z(int g[4])
{
int i,j,h[4]; LL S=0;
for(i=0;i<4;i++) h[i]=g[i];
for(i=1;i<4;i++){
for(j=0;j<4;j++)
if(g[(j+i)&3]!=h[j]) break;
if(j<4&&g[(j+i)&3]<h[j])
for(j=0;j<4;j++) h[j]=g[(j+i)&3];
}
for(i=0;i<4;i++)
S=S*1000+h[i];
return S;
}
void ins(LL S,int d)
{
int i,u=S%mo;
for(i=0;i<G[u].size();i++)
if(G[u][i].first==S){ G[u][i].second+=d; return ;}
G[u].push_back(PAIR(S,d));
}
int cnt(LL S)
{
int i,u=S%mo;
for(i=0;i<G[u].size();i++)
if(G[u][i].first==S) return G[u][i].second;
return 0;
}
int cir(LL S)
{
int i,j,g[4],cnt=0;
g[0]=S/1000000000;
g[1]=(S/1000000)%1000;
g[2]=(S/1000)%1000;
g[3]=S%1000;
for(i=0;i<4;i++){
for(j=0;j<4;j++)
if(g[j]!=g[(j+i)&3]) break;
if(j>=4) cnt++;
}
return cnt;
}
int main()
{
int i,j,k,l,p,q; LL v;
scanf("%d",&n);
for(i=1;i<=n;i++){
for(j=0;j<4;j++)
scanf("%d ",&c[i][j]);
for(j=0;j<4;j++)
ins(H(c[i],j),1);
}
for(i=1;i<=n;i++){
for(j=0;j<4;j++) ins(H(c[i],j),-1);
for(j=0;j<=0;j++)
for(k=i+1;k<=n;k++){
for(l=0;l<4;l++) ins(H(c[k],l),-1);
for(l=0;l<4;l++){
f[0]=c[k][(l+1)&3],f[1]=c[k][l],f[2]=c[i][(j+1)&3],f[3]=c[i][j],v=Z(f),z[0]=PAIR(v,cnt(v));
f[0]=c[i][(j+3)&3],f[1]=c[i][(j+2)&3],f[2]=c[k][(l+3)&3],f[3]=c[k][(l+2)&3],v=Z(f),z[1]=PAIR(v,cnt(v));
f[0]=c[k][(l+1)&3],f[1]=c[i][j],f[2]=c[i][(j+3)&3],f[3]=c[k][(l+2)&3],v=Z(f),z[2]=PAIR(v,cnt(v));
f[0]=c[i][(j+1)&3],f[1]=c[k][l],f[2]=c[k][(l+3)&3],f[3]=c[i][(j+2)&3],v=Z(f),z[3]=PAIR(v,cnt(v));
sort(z,z+4),q=0,now=1;
for(p=0;p<4;p++){
if(p&&z[p].first==z[p-1].first) q+=cir(z[p].first); else q=0;
now*=(z[p].second-q);
}
ans+=now;
}
for(l=0;l<4;l++) ins(H(c[k],l),1);
}
for(j=0;j<4;j++) ins(H(c[i],j),1);
}
cout<<ans/3;
return 0;
}
Submission Info
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:62:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:65:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d ",&c[i][j]);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
900 / 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 |
AC |
12 ms |
23808 KB |
0_001.txt |
AC |
12 ms |
23680 KB |
0_002.txt |
AC |
12 ms |
23680 KB |
1_003.txt |
AC |
73 ms |
23680 KB |
1_004.txt |
AC |
16 ms |
23680 KB |
1_005.txt |
AC |
62 ms |
23680 KB |
1_006.txt |
AC |
48 ms |
23680 KB |
1_007.txt |
AC |
60 ms |
23680 KB |
1_008.txt |
AC |
56 ms |
23680 KB |
1_009.txt |
AC |
64 ms |
23680 KB |
1_010.txt |
AC |
20 ms |
23680 KB |
1_011.txt |
AC |
69 ms |
23680 KB |
1_012.txt |
AC |
12 ms |
23680 KB |
1_013.txt |
AC |
61 ms |
23680 KB |
1_014.txt |
AC |
12 ms |
23680 KB |
1_015.txt |
AC |
96 ms |
23680 KB |
1_016.txt |
AC |
34 ms |
23680 KB |
1_017.txt |
AC |
88 ms |
23680 KB |
1_018.txt |
AC |
87 ms |
23680 KB |
1_019.txt |
AC |
93 ms |
23680 KB |