Submission #932033


Source Code Expand

Copy
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 400
int aa[] = {4, 0, 3, 7}, bb[] = {1, 5, 6, 2}, cc[] = {5, 4, 7, 6};
int n;
vector<int> c[N];
vector<int> c2[4*N];
vector<int> c3[N];
int rr[N];
map<vector<int>, int> cnt;

void rot(vector<int> &a){
	int t = a[0];
	rep(i, 3) a[i] = a[i+1];
	a[3] = t;
}

void rot2(vector<int> &a){
	vector<int> b(a);
	rep(i, 3){
		rot(b);
		if(a>b) a = b;
	}
}

int f(vector<int> &a){
	if(a[0]!=a[2] || a[1]!=a[3]) return 1;
	if(a[0]!=a[1]) return 2;
	return 4;
}

int main(){
	cin>>n;
	rep(i, n){
		c[i] = vector<int>(4);
		rep(j, 4) cin>>c[i][j];
		rot2(c[i]);
		c3[i] = c[i];
		rr[i] = f(c[i]);
		rep(j, 4){
			c2[i*4+j] = c[i];
			++cnt[c[i]];
			rot(c[i]);
		}

	}
	ll res = 0;
	vector<int> e(8);
	for(int i = 0; i < n; i++){
		rep(_, 4) e[_] = c[i][_];
		for(int jj = 0; jj < n*4; jj++){
			int j = jj/4, j2 = j%4;
			if(i==j) continue;
			//if(rr[j]*(j2)>=4) continue;
			if(!(c2[jj][2]==c[i][1]&&c2[jj][3]==c[i][0])) continue;
			e[4] = c2[jj][0];
			e[5] = c2[jj][1];
			for(int kk = 0; kk < n*4; kk++){
				int k = kk/4, k2 = k%4;
				if(i==k || j==k) continue;
				//if((rr[k]*k2)>=4) continue;
				if(!(c2[kk][0]==c[i][3]&&c2[kk][1]==c[i][2])) continue;
				e[6] = c2[kk][2];
				e[7] = c2[kk][3];

				vector<int> a(4), b(4), c(4);
				rep(_, 4){
					a[_] = e[aa[_]];
					b[_] = e[bb[_]];
					c[_] = e[cc[_]];
				}
				rot2(a); rot2(b); rot2(c);
				if(!cnt[a]||!cnt[b]||!cnt[c]) continue;
				ll tres = 0;
				if(a==b && b==c){
					ll t = cnt[a];
					ll r = f(a);
					ll s = 0;
					if(c3[i]==a) s++;
					if(c3[j]==a) s++;
					if(c3[k]==a) s++;
					t -= s*r;
					tres = t*(t-r)*(t-r*2);
				} else {
					if(a==c) swap(b, c);
					if(b==c) swap(a, c);
					if(a==b){
						ll t = cnt[a];
						ll r = f(a), r2 = f(c);
						ll s = 0, s2 = 0;
						if(c3[i]==a) s++;
						if(c3[j]==a) s++;
						if(c3[k]==a) s++;
						if(c3[i]==c) s2++;
						if(c3[j]==c) s2++;
						if(c3[k]==c) s2++;
						t -= s*r;
						tres = t*(t-r)*(cnt[c]-s2*r2);
					} else {
						ll r = f(a), r2 = f(b), r3 = f(c);
						ll s = 0, s2 = 0, s3 = 0;
						if(c3[i]==a) s++;
						if(c3[j]==a) s++;
						if(c3[k]==a) s++;
						if(c3[i]==b) s2++;
						if(c3[j]==b) s2++;
						if(c3[k]==b) s2++;
						if(c3[i]==c) s3++;
						if(c3[j]==c) s3++;
						if(c3[k]==c) s3++;
						tres = (cnt[a]-s*r)*(cnt[b]-s2*r2)*(cnt[c]-s3*r3);
					}
				}
				//res += tres*rr[j]*rr[k];
				res += tres;
			}
		}
	}
	cout<<res/6<<endl;
	return 0;
}

Submission Info

Submission Time
Task E - Building Cubes with AtCoDeer
User Lepton
Language C++14 (GCC 5.4.1)
Score 0
Code Size 3713 Byte
Status
Exec Time 4202 ms
Memory 768 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_000.txt, 0_001.txt, 0_002.txt
All 0 / 900 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 3 ms 256 KB
0_001.txt 3 ms 256 KB
0_002.txt 3 ms 256 KB
1_003.txt 4202 ms 384 KB
1_004.txt 4202 ms 256 KB
1_005.txt 4202 ms 384 KB
1_006.txt 4202 ms 384 KB
1_007.txt 4202 ms 384 KB
1_008.txt 4202 ms 384 KB
1_009.txt 1381 ms 384 KB
1_010.txt 65 ms 384 KB
1_011.txt 88 ms 768 KB
1_012.txt 3 ms 384 KB
1_013.txt 6 ms 512 KB
1_014.txt 3 ms 384 KB
1_015.txt 6 ms 512 KB
1_016.txt 4 ms 384 KB
1_017.txt 6 ms 512 KB
1_018.txt 7 ms 512 KB
1_019.txt 9 ms 512 KB