Submission #1688551


Source Code Expand

#include<bits/stdc++.h>
#define LL long long
using namespace std;
#define G(x,y,z,t) ((x)*1LL*1000000000+(y)*1000000+(z)*1000+(t))
unordered_map<LL,int> number;
struct sqare{
	int x0,x1,x2,x3;
	LL key[5];
	void ini(int a,int b,int c,int d){
		x0=a,x1=b,x2=c,x3=d;
		key[1]=G(a,b,c,d);
		key[2]=G(b,c,d,a);
		key[3]=G(c,d,a,b);
		key[4]=G(d,a,b,c);
	}
	void add(){
		for(int i=1;i<=4;i++) number[key[i]]++;
	}
	void dec(){
		for(int i=1;i<=4;i++) number[key[i]]--;
	}
}p[505];
LL calc(sqare fr,sqare bk){
	fr.dec();bk.dec();
	LL ret=0;
	for(int i=1;i<=4;i++){
		int t=bk.x0;bk.x0=bk.x1;bk.x1=bk.x2;bk.x2=bk.x3;bk.x3=t;
		LL ans=1;sqare key[5];
		key[1].ini(fr.x1,fr.x0,bk.x1,bk.x0);
		ans*=number[G(fr.x1,fr.x0,bk.x1,bk.x0)];key[1].dec();
		key[2].ini(fr.x2,fr.x1,bk.x0,bk.x3);
		ans*=number[G(fr.x2,fr.x1,bk.x0,bk.x3)];key[2].dec();
		key[3].ini(fr.x3,fr.x2,bk.x3,bk.x2);
		ans*=number[G(fr.x3,fr.x2,bk.x3,bk.x2)];key[3].dec();
		key[4].ini(fr.x0,fr.x3,bk.x2,bk.x1);
		ans*=number[G(fr.x0,fr.x3,bk.x2,bk.x1)];
		ret+=ans;
		for(int j=1;j<=3;j++) key[j].add();
	}
	fr.add();bk.add();
	return ret;
}
int n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		p[i].ini(a,b,c,d);
		p[i].add();
	}
	LL ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i!=j)
				ans+=calc(p[i],p[j]);
	cout<<ans/6<<endl;
	return 0;
}

Submission Info

Submission Time
Task E - Building Cubes with AtCoDeer
User Wuvin
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1430 Byte
Status TLE
Exec Time 4214 ms
Memory 239576 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:45:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
./Main.cpp:48:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d%d",&a,&b,&c,&d);
                                ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 900
Status
AC × 3
AC × 16
TLE × 4
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 512 KB
0_001.txt AC 1 ms 256 KB
0_002.txt AC 1 ms 256 KB
1_003.txt AC 247 ms 256 KB
1_004.txt AC 19 ms 256 KB
1_005.txt AC 250 ms 256 KB
1_006.txt AC 180 ms 256 KB
1_007.txt AC 344 ms 256 KB
1_008.txt AC 305 ms 256 KB
1_009.txt AC 306 ms 256 KB
1_010.txt AC 48 ms 256 KB
1_011.txt AC 310 ms 640 KB
1_012.txt AC 4 ms 512 KB
1_013.txt AC 3514 ms 166744 KB
1_014.txt AC 12 ms 2316 KB
1_015.txt TLE 4214 ms 239448 KB
1_016.txt AC 765 ms 59600 KB
1_017.txt TLE 4213 ms 239576 KB
1_018.txt TLE 4212 ms 239448 KB
1_019.txt TLE 4213 ms 239448 KB