Submission #1690183


Source Code Expand

///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//                       _oo0oo_                         //
//                      o8888888o                        //
//                      88" . "88      ------ hzt1       //
//                      (| -_- |)                        //
//                      0\  =  /0                        //
//                    ___/`---'\___                      //
//                  .' \|     |// '.                     //
//                 / \|||  :  |||// \                    //
//                / _||||| -:- |||||- \                  //
//               |   | \  -  /// |     |                 //
//               | \_|  ''\---/''  |_/ |                 //
//               \  .-\__  '-'  ___/-. /                 //
//             ___'. .'  /--.--\  `. .'___               //
//          ."" '<  `.___\_<|>_/___.' >' "".             //
//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |           //
//         \  \ `_.   \_ __\ /__ _/   .-` /  /           //
//     =====`-.____`.___ \_____/___.-`___.-'=====        //
//                       `=---='                         //
//                                                       //
//                                                       //
//     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       //
//                                                       //
//                 God-He Bless All.                     //
//           This Code Will Never Explode.               //
//                                                       //
//                                                       //
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#include<cstdio>
#include<cstring>
#include<cctype>
#include<map>
#include<algorithm>
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,Size,stdin);
        tail=(head=buffer)+l;
    }
    if(head==tail) return -1;
    return *head++;
}
inline int read() {
    int x=0,f=1;char c=Getchar();
    for(;!isdigit(c);c=Getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=Getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
const int maxn=410;
struct State {
	int a,b,c,d;
	bool operator < (const State& S) const {
		if(a!=S.a) return a<S.a;
		if(b!=S.b) return b<S.b;
		if(c!=S.c) return c<S.c;
		return d<S.d;
	}
	bool operator == (const State& S) {
		return a==S.a&&b==S.b&&c==S.c&&d==S.d;
	}
}A[maxn][4];
map<State,int> M;
void del(State x) {
	M[(State){x.a,x.b,x.c,x.d}]--;
	M[(State){x.b,x.c,x.d,x.a}]--;
	M[(State){x.c,x.d,x.a,x.b}]--;
	M[(State){x.d,x.a,x.b,x.c}]--;
}
void add(State x) {
	M[(State){x.a,x.b,x.c,x.d}]++;
	M[(State){x.b,x.c,x.d,x.a}]++;
	M[(State){x.c,x.d,x.a,x.b}]++;
	M[(State){x.d,x.a,x.b,x.c}]++;
}
int main() {
	int n=read();
	rep(i,1,n) {
		int a=read(),b=read(),c=read(),d=read();
		A[i][0]=(State){a,b,c,d};
		A[i][1]=(State){b,c,d,a};
		A[i][2]=(State){c,d,a,b};
		A[i][3]=(State){d,a,b,c};
		M[A[i][0]]++;M[A[i][1]]++;M[A[i][2]]++;M[A[i][3]]++;
	}
	ll ans=0;
	rep(i,1,n) rep(j,i+1,n) if(i!=j) {
		del(A[i][0]);del(A[j][0]);
		rep(y,0,3) {
			swap(A[j][y].a,A[j][y].b);swap(A[j][y].c,A[j][y].d);
			State S[4];
			S[0]=(State){A[i][0].b,A[i][0].a,A[j][y].a,A[j][y].b};
			S[1]=(State){A[j][y].b,A[j][y].c,A[i][0].c,A[i][0].b};
			S[2]=(State){A[i][0].d,A[i][0].c,A[j][y].c,A[j][y].d};
			S[3]=(State){A[j][y].a,A[i][0].a,A[i][0].d,A[j][y].d};
			int c1=M[S[0]];del(S[0]);
			int c2=M[S[1]];del(S[1]);
			int c3=M[S[2]];del(S[2]);
			int c4=M[S[3]];del(S[3]);
			ans+=(ll)c1*c2*c3*c4;
			rep(k,0,3) add(S[k]);
			swap(A[j][y].a,A[j][y].b);swap(A[j][y].c,A[j][y].d);
		}
		add(A[i][0]);add(A[j][0]);
	}
	printf("%lld\n",ans/3);
	return 0;
}

Submission Info

Submission Time
Task E - Building Cubes with AtCoDeer
User wzj52501
Language C++14 (GCC 5.4.1)
Score 0
Code Size 4115 Byte
Status TLE
Exec Time 4221 ms
Memory 257152 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 900
Status
AC × 3
AC × 15
TLE × 5
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 2 ms 256 KB
0_001.txt AC 1 ms 256 KB
0_002.txt AC 1 ms 256 KB
1_003.txt AC 98 ms 256 KB
1_004.txt AC 8 ms 256 KB
1_005.txt AC 182 ms 256 KB
1_006.txt AC 130 ms 256 KB
1_007.txt AC 294 ms 256 KB
1_008.txt AC 268 ms 256 KB
1_009.txt AC 725 ms 256 KB
1_010.txt AC 114 ms 256 KB
1_011.txt AC 1444 ms 896 KB
1_012.txt AC 10 ms 640 KB
1_013.txt TLE 4216 ms 186240 KB
1_014.txt AC 30 ms 3456 KB
1_015.txt TLE 4219 ms 222080 KB
1_016.txt AC 1468 ms 88064 KB
1_017.txt TLE 4220 ms 242048 KB
1_018.txt TLE 4221 ms 257152 KB
1_019.txt TLE 4220 ms 244224 KB