Submission #150993

# Submission time Handle Problem Language Result Execution time Memory
150993 2019-09-01T14:06:49 Z pichulia FunctionCup Museum (FXCUP4_museum) C++17
100 / 100
81 ms 11108 KB
#include "museum.h"
#include<vector>
#include<algorithm>
using namespace std;
int a[102];
int b[102];
int c[102];
int ab[102][102];
int bc[102][102];
int ca[102][102];
int abc[102][102][102];
long long cal(int x) {
	long long int res = x;
	return res * (res - 1) / 2;
}
long long CountSimilarPairs(std::vector<int> x, std::vector<int> y, std::vector<int> z) {
	int n = x.size();
	long long int res = 0;
	int i, j, k;
	for (i = 0; i < n; i++)
	{
		a[x[i]]++;
		b[y[i]]++;
		c[z[i]]++;
		ab[x[i]][y[i]]++;
		bc[y[i]][z[i]]++;
		ca[z[i]][x[i]]++;
		abc[x[i]][y[i]][z[i]]++;
	}
	for (i = 1; i <= 100; i++)
	{
		res += cal(a[i]);
		res += cal(b[i]);
		res += cal(c[i]);
		for (j = 1; j <= 100; j++) {
			res -= cal(ab[i][j]);
			res -= cal(bc[i][j]);
			res -= cal(ca[i][j]);
			for (k = 1; k <= 100; k++) {
				res += cal(abc[i][j][k]);
			}
		}
	}
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 632 KB Output is correct
5 Correct 5 ms 1656 KB Output is correct
6 Correct 6 ms 2196 KB Output is correct
7 Correct 6 ms 2936 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 7 ms 4008 KB Output is correct
10 Correct 7 ms 3960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 632 KB Output is correct
5 Correct 5 ms 1656 KB Output is correct
6 Correct 6 ms 2196 KB Output is correct
7 Correct 6 ms 2936 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 7 ms 4008 KB Output is correct
10 Correct 7 ms 3960 KB Output is correct
11 Correct 8 ms 4600 KB Output is correct
12 Correct 15 ms 1272 KB Output is correct
13 Correct 27 ms 5876 KB Output is correct
14 Correct 43 ms 7360 KB Output is correct
15 Correct 52 ms 8560 KB Output is correct
16 Correct 71 ms 6308 KB Output is correct
17 Correct 74 ms 6468 KB Output is correct
18 Correct 79 ms 8164 KB Output is correct
19 Correct 81 ms 10984 KB Output is correct
20 Correct 81 ms 11108 KB Output is correct