Submission #148542

# Submission time Handle Problem Language Result Execution time Memory
148542 2019-09-01T04:38:04 Z =SUM(D1:D9)(#3629, ydk1104, stet_stet, Hyperbolic) FunctionCup Museum (FXCUP4_museum) C++17
0 / 100
6 ms 384 KB
#include "museum.h"

long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
	long long a[20]={0, }, b[20]={0, }, c[20]={0, }, ab[300] = {0, }, bc[300] = {0,}, ac[300] = {0,}, abc[4200] = {0,};
	int N = B.size();
	for(int i=0; i<N; i++){
		int na = B[i], nb = T[i], nc = G[i];
		a[na]++, b[nb]++, c[nc]++;
		ab[na*15+nb]++, ac[na*15+nc]++, bc[nb*15+nc]++;
		abc[na*15*15 + nb*15 + nc]++;
	}
	long long ans = 0;
	for(int i=0; i<20; i++){
		ans += (a[i] * (a[i]-1) / 2);
		ans += (b[i] * (b[i]-1) / 2);
		ans += (c[i] * (c[i]-1) / 2);
	}
	for(int i=0; i<300; i++){
		ans -= (ab[i] * (ab[i]-1) / 2);
		ans -= (ac[i] * (ac[i]-1) / 2);
		ans -= (bc[i] * (bc[i]-1) / 2);
	}
	for(int i=0; i<4100; i++){
		ans += (abc[i] * (abc[i]-1) / 2);
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Runtime error 5 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Runtime error 5 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -