Submission #1653580


Source Code Expand

#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000000000000ll
#define N 409
using namespace std;

int n,a[N][4]; ll ans,sum,p[N],q[4];
struct hsh{
	int tot,fst[20000003],sz[N],tp[N],nxt[N]; ll pnt[N];
	void ins(ll x,int y){
		int i,z=x%20000003;
		for (i=fst[z]; i; i=nxt[i]) if (pnt[i]==x){
			sz[i]+=y; return;
		}
		pnt[++tot]=x; sz[tot]=y;
		if ((x>>20)==(x&(1<<20)-1))
			tp[tot]=((x>>30)==(x&(1<<10)-1)?4:2);
		else tp[tot]=1;
		nxt[tot]=fst[z]; fst[z]=tot;
	}
	void solve(ll &x){
		int i,z=x%20000003;
		for (i=fst[z]; i; i=nxt[i]) if (pnt[i]==x){
			sum*=tp[i]*(sz[i]--);
			return;
		}
		x=-1; sum=0;
	}
}hsh;
ll calc(int x1,int x2,int x3,int x4){
	int num[4]={x1,x2,x3,x4},i,j; ll tmp,mn=inf;
	for (i=0; i<4; i++){
		for (j=0,tmp=0; j<4; j++) tmp=tmp<<10|num[(i+j)&3];
		mn=min(mn,tmp);
	}
	return mn;
}
int main(){
	scanf("%d",&n);
	int i,j,k,l;
	for (i=1; i<=n; i++){
		for (j=0; j<4; j++) scanf("%d",&a[i][j]);
		p[i]=calc(a[i][0],a[i][1],a[i][2],a[i][3]);
		hsh.ins(p[i],1);
	}
	for (i=1; i<n; i++){
		hsh.ins(p[i],-1);
		for (j=i+1; j<=n; j++){
			hsh.ins(p[j],-1);
			for (k=0; k<4; k++){
				for (l=0,sum=1; l<4; l++){
					q[l]=calc(a[i][(l+1)&3],a[i][l],a[j][(k-l+5)&3],a[j][(k-l+4)&3]);
					hsh.solve(q[l]);
				}
				ans+=sum;
				for (l=0; l<4; l++) if (q[l]!=-1) hsh.ins(q[l],1);
			}
			hsh.ins(p[j],1);
		}
		hsh.ins(p[i],1);
	}
	printf("%lld\n",ans/3);
	return 0;
}

Submission Info

Submission Time
Task E - Building Cubes with AtCoDeer
User lych_cys
Language C++14 (GCC 5.4.1)
Score 900
Code Size 1474 Byte
Status AC
Exec Time 119 ms
Memory 76160 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:39:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
./Main.cpp:42:43: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   for (j=0; j<4; j++) scanf("%d",&a[i][j]);
                                           ^

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 3 ms 8448 KB
0_001.txt AC 2 ms 4352 KB
0_002.txt AC 1 ms 256 KB
1_003.txt AC 34 ms 256 KB
1_004.txt AC 4 ms 256 KB
1_005.txt AC 35 ms 4352 KB
1_006.txt AC 26 ms 4352 KB
1_007.txt AC 37 ms 10496 KB
1_008.txt AC 33 ms 10496 KB
1_009.txt AC 41 ms 24832 KB
1_010.txt AC 11 ms 24832 KB
1_011.txt AC 40 ms 37248 KB
1_012.txt AC 6 ms 26880 KB
1_013.txt AC 76 ms 76160 KB
1_014.txt AC 11 ms 45312 KB
1_015.txt AC 113 ms 76032 KB
1_016.txt AC 43 ms 76032 KB
1_017.txt AC 119 ms 76160 KB
1_018.txt AC 113 ms 76032 KB
1_019.txt AC 118 ms 76032 KB