Submission #1914225


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=min(x,y))
#define chmax(x,y) (x=max(x,y))
#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 500

vector<vector<int>> a;
map<vector<int>, ll> cnt, mul;

void norm(vector<int> &a){
	vector<int> b(a);
	rep(i, 4){
		if(b<a) a = b;
		rotate(b.begin(), b.begin()+1, b.end());
	}
}

int main(){
	int n;
	cin>>n;
	a = vector<vector<int>>(n, vector<int>(4));
	rep(i, n){
		rep(j, 4) cin>>a[i][j];
	}
	rep(i, n) norm(a[i]);
	//sort(all(a));
	rep(i, n) ++cnt[a[i]];
	rep(i, n){
		vector<int> b(a[i]);
		if(mul[b]) continue;
		rep(j, 4){
			if(b==a[i]) ++mul[b];
			rotate(b.begin(), b.begin()+1, b.end());
		}
	}
	ll res = 0;
	rep(i, n){
		--cnt[a[i]];
		vector<int> ai(a[i]);
		rep(j, i){
			--cnt[a[j]];
			vector<int> aj(a[j]); swap(aj[1], aj[3]);
			rep(k, 4){
				vector<vector<int>> b(4, vector<int>(4));
				rep(l, 4){
					b[l][1] = ai[(l+0)%4];
					b[l][0] = ai[(l+1)%4];
					b[l][3] = aj[(l+1)%4];
					b[l][2] = aj[(l+0)%4];
					norm(b[l]);
				}
				/*cerr<<"dubug: "<<i<<" "<<j<<endl;
				cerr<<ai<<endl;
				cerr<<aj<<endl;
				rep(l, 4) cerr<<b[l]<<endl;
				cerr<<endl;*/
				ll r = 1;
				rep(l, 4){
					r *= cnt[b[l]]--*mul[b[l]];
				}
				res += r;
				rep(l, 4) ++cnt[b[l]];
				rotate(aj.begin(), aj.begin()+1, aj.end());
			}
			++cnt[a[j]];
		}
		++cnt[a[i]];
	}
	cout<<res/3<<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 2428 Byte
Status
Exec Time 2496 ms
Memory 279680 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 1 ms 256 KB
0_001.txt 1 ms 256 KB
0_002.txt 1 ms 256 KB
1_003.txt 250 ms 256 KB
1_004.txt 19 ms 256 KB
1_005.txt 312 ms 256 KB
1_006.txt 215 ms 256 KB
1_007.txt 365 ms 256 KB
1_008.txt 330 ms 256 KB
1_009.txt 504 ms 256 KB
1_010.txt 75 ms 256 KB
1_011.txt 778 ms 768 KB
1_012.txt 6 ms 640 KB
1_013.txt 2472 ms 238464 KB
1_014.txt 16 ms 3200 KB
1_015.txt 2430 ms 279296 KB
1_016.txt 576 ms 77056 KB
1_017.txt 2435 ms 279680 KB
1_018.txt 2463 ms 279168 KB
1_019.txt 2496 ms 275712 KB