Submission #1865534


Source Code Expand

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int 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();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=10005;
int n;
struct info{
	int a,b,c,d;
	inline info(){}
	inline info(int _a,int _b,int _c,int _d){
		a=_a;b=_b;c=_c;d=_d;
	}
	inline pair<pin,pin> val(){
		return mk(mk(a,b),mk(c,d));
	}
	inline info rotate(){
		return info(b,c,d,a);
	}
};
map<pair<pin,pin>,i64> f;
inline void add(info cur,int delta){
	rep(k,0,3){
		f[cur.val()]+=delta;
		cur=cur.rotate();
	}
}
inline int query(info cur){
	return f[cur.val()];
}
info a[maxn];
int main(){
	read(n);rep(i,1,n){
		read(a[i].a);
		read(a[i].b);
		read(a[i].c);
		read(a[i].d);
		add(a[i],1);
	}
	i64 res=0;
	rep(i,1,n-1){
		add(a[i],-1);
		rep(j,i+1,n){
			add(a[j],-1);
			info cur=a[j];
			rep(k,0,3){
				info f1=info(cur.b,cur.a,a[i].b,a[i].a);
				info f2=info(cur.a,cur.d,a[i].c,a[i].b);
				info f3=info(cur.d,cur.c,a[i].d,a[i].c);
				info f4=info(cur.c,cur.b,a[i].a,a[i].d);
 				i64 ways=1;
				ways*=query(f1),add(f1, -1);
				ways*=query(f2),add(f2, -1);
				ways*=query(f3),add(f3, -1);
				ways*=query(f4);
				add(f1,1);add(f2,1);add(f3,1);
				res+=ways;
				cur=cur.rotate();
			}
			add(a[j],1);
		}
	}
	cout<<res<<endl;
	return 0;
}

Submission Info

Submission Time
Task E - Building Cubes with AtCoDeer
User Scape
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2083 Byte
Status TLE
Exec Time 4216 ms
Memory 259712 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 900
Status
AC × 3
AC × 15
TLE × 2
MLE × 3
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 1 ms 256 KB
0_001.txt AC 1 ms 256 KB
0_002.txt AC 1 ms 256 KB
1_003.txt AC 77 ms 256 KB
1_004.txt AC 7 ms 256 KB
1_005.txt AC 142 ms 256 KB
1_006.txt AC 99 ms 256 KB
1_007.txt AC 230 ms 256 KB
1_008.txt AC 209 ms 256 KB
1_009.txt AC 563 ms 256 KB
1_010.txt AC 88 ms 256 KB
1_011.txt AC 1158 ms 896 KB
1_012.txt AC 8 ms 640 KB
1_013.txt TLE 4216 ms 226432 KB
1_014.txt AC 22 ms 2944 KB
1_015.txt MLE 3997 ms 259584 KB
1_016.txt AC 879 ms 71680 KB
1_017.txt MLE 3877 ms 259712 KB
1_018.txt MLE 3995 ms 259328 KB
1_019.txt TLE 4184 ms 256768 KB