Submission #1521446


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using Square = array<int, 4>;

map<Square, ll> memo;

const Square indices[] = {{1,0,1,0},{2,1,0,3},{3,2,3,2},{0,3,2,1}};

void normalize(Square& s) {
	set<Square> tmp;
	for (int i = 0; i < 4; i++) {
		tmp.insert(s);
		rotate(s.begin(), s.begin() + 1, s.end());
	}
	s = *tmp.begin();
}

int pattern(Square& s) {
	if (s[0] == s[2] && s[1] == s[3]) {
		if (s[0] == s[1]) return 4;
		else return 2;
	}
	return 1;
}

ll solve(const Square& s1, const Square& s2) {
	ll res = 1;
	int used = -1;
	for (int i = 0; i < 4; i++) {
		Square tmp = {s1[indices[i][0]], s1[indices[i][1]], s2[indices[i][2]], s2[indices[i][3]]};
		normalize(tmp);
		if (memo.find(tmp) == memo.end() || memo[tmp] == 0) {
			res = 0;
			break;
		}
		res *= memo[tmp] * pattern(tmp);
		memo[tmp]--;
		used++;
	}

	for (int i = 0; i <= used; i++) {
		Square tmp = {s1[indices[i][0]], s1[indices[i][1]], s2[indices[i][2]], s2[indices[i][3]]};
		normalize(tmp);
		memo[tmp]++;	
	}
	return res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<Square> c(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			cin >> c[i][j];
		}
		normalize(c[i]);
		memo[c[i]]++;
		for (int j = 0; j < 4; j++) {
			cout << c[i][j] << " ";
		}
		cout << endl;
	}

	ll ans = 0;
	for (int i = 0; i < n; i++) {
		memo[c[i]]--;
		for (int j = 0; j < i; j++) {
			memo[c[j]]--;
			for (int k = 0; k < 4; k++) {
				ans += solve(c[i], c[j]);
				rotate(c[j].begin(), c[j].begin() + 1, c[j].end());
			}
			memo[c[j]]++;
		}
		memo[c[i]]++;	
	}
	cout << ans / 3 << endl;
	return 0;
}

Submission Info

Submission Time
Task E - Building Cubes with AtCoDeer
User fine
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1725 Byte
Status WA
Exec Time 859 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 900
Status
WA × 3
WA × 20
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 WA 1 ms 256 KB
0_001.txt WA 1 ms 256 KB
0_002.txt WA 1 ms 256 KB
1_003.txt WA 411 ms 256 KB
1_004.txt WA 31 ms 256 KB
1_005.txt WA 745 ms 256 KB
1_006.txt WA 524 ms 256 KB
1_007.txt WA 859 ms 256 KB
1_008.txt WA 761 ms 256 KB
1_009.txt WA 839 ms 256 KB
1_010.txt WA 67 ms 256 KB
1_011.txt WA 168 ms 256 KB
1_012.txt WA 2 ms 256 KB
1_013.txt WA 112 ms 256 KB
1_014.txt WA 2 ms 256 KB
1_015.txt WA 109 ms 256 KB
1_016.txt WA 30 ms 256 KB
1_017.txt WA 109 ms 256 KB
1_018.txt WA 109 ms 256 KB
1_019.txt WA 111 ms 256 KB