Submission #148594

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

long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
	int MAX = 101;
	long long a[MAX+1]={0, }, b[MAX+1]={0, }, c[MAX+1]={0, }, ab[MAX*MAX+1] = {0, }, bc[MAX*MAX+1] = {0,}, ac[MAX*MAX+1] = {0,}, abc[MAX*MAX*MAX+1] = {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*MAX+nb]++, ac[na*MAX+nc]++, bc[nb*MAX+nc]++;
		abc[na*MAX*MAX + nb*MAX + nc]++;
	}
	long long ans = 0;
	for(int i=0; i<=MAX; 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<=MAX*MAX; 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<=MAX*MAX*MAX; i++){
		ans += (abc[i] * (abc[i]-1) / 2);
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 12 ms 8704 KB Output is correct
2 Correct 11 ms 8704 KB Output is correct
3 Correct 10 ms 8704 KB Output is correct
4 Correct 11 ms 8576 KB Output is correct
5 Correct 11 ms 8448 KB Output is correct
6 Correct 12 ms 8704 KB Output is correct
7 Correct 11 ms 8576 KB Output is correct
8 Correct 13 ms 8704 KB Output is correct
9 Correct 13 ms 8704 KB Output is correct
10 Correct 13 ms 8704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 8704 KB Output is correct
2 Correct 11 ms 8704 KB Output is correct
3 Correct 10 ms 8704 KB Output is correct
4 Correct 11 ms 8576 KB Output is correct
5 Correct 11 ms 8448 KB Output is correct
6 Correct 12 ms 8704 KB Output is correct
7 Correct 11 ms 8576 KB Output is correct
8 Correct 13 ms 8704 KB Output is correct
9 Correct 13 ms 8704 KB Output is correct
10 Correct 13 ms 8704 KB Output is correct
11 Correct 13 ms 8832 KB Output is correct
12 Correct 22 ms 9472 KB Output is correct
13 Correct 36 ms 10100 KB Output is correct
14 Correct 49 ms 10736 KB Output is correct
15 Correct 64 ms 11760 KB Output is correct
16 Correct 83 ms 13540 KB Output is correct
17 Correct 87 ms 13544 KB Output is correct
18 Correct 86 ms 13548 KB Output is correct
19 Correct 93 ms 13548 KB Output is correct
20 Correct 92 ms 13548 KB Output is correct