Submission #149029

#TimeUsernameProblemLanguageResultExecution timeMemory
149029usa1+samsung2 (#200)FunctionCup Museum (FXCUP4_museum)C++17
100 / 100
97 ms13548 KiB
#include "museum.h"
#include <algorithm>

long long b[105] = { 0 }, t[105] = { 0 }, g[105] = { 0 };
long long bb[101 * 101] = { 0 }, tt[101 * 101] = { 0 }, gg[101 * 101] = { 0 };
long long tot[101 * 101 * 101] = { 0 };

#define AB B[i] * 101 + T[i]
#define BC T[i] * 101 + G[i]
#define AC B[i] * 101 + G[i]
#define ABC B[i] * 101 * 101 + T[i] * 101 + G[i]

long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {

	for (int i = 0; i < 101 * 101 * 101; i++) tot[i] = 0;
	for (int i = 0; i < 101 * 101; i++) bb[i] = tt[i] = gg[i] = 0;
	for (int i = 0; i < 105; i++) b[i] = t[i] = g[i] = 0;

	long long n = B.size();
	
	long long ans = 0;

	for (int i = 0; i < n; i++) {
		ans += b[B[i]] + t[T[i]] + g[G[i]] - bb[AB] - tt[BC] - gg[AC] + tot[ABC];
		b[B[i]]++;
		t[T[i]]++;
		g[G[i]]++;
		bb[AB]++;
		tt[BC]++;
		gg[AC]++;
		tot[ABC]++;
	}

	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...