Submission #151471

# Submission time Handle Problem Language Result Execution time Memory
151471 2019-09-03T11:06:04 Z leduykhongngu FunctionCup Museum (FXCUP4_museum) C++17
100 / 100
83 ms 10892 KB
#include <cstring>
#include <vector>
int cnt1[101],cnt2[101][101], cnt3[101][101][101];
long long Solve(const std::vector< int > &A)
{
	memset(cnt1,0,sizeof(cnt1));
	for (int x : A)
		++cnt1[x];
	long long res = 0;
	for (int i = 1; i <= 100; ++i)
		res+=1ll*cnt1[i] *(cnt1[i]-1) /2;
	return res;
}
long long Solve2(const std::vector< int > &A, const std::vector< int > &B) {
	memset(cnt2, 0, sizeof(cnt2));
	for (int i = 0; i < A.size(); ++ i)
		++cnt2[A[i]][B[i]];
	long long res = 0;
	for (int i = 1; i <= 100; ++i)
		for (int j = 0; j <= 100; ++j)
			res+=1ll*cnt2[i][j]*(cnt2[i][j]-1)/2;
	return res;
}
long long Solve3(const std::vector< int > &A, const std::vector< int > &B, const std::vector< int > &C) {
	memset(cnt3, 0, sizeof(cnt3));
	for (int i = 0; i < A.size(); ++ i)
		++cnt3[A[i]][B[i]][C[i]];
	long long res = 0;
	for (int i = 1; i <= 100; ++i)
		for (int j = 0; j <= 100; ++j)
			for (int k = 0; k <= 100; ++k)
				res+=1ll*cnt3[i][j][k]*(cnt3[i][j][k]-1)/2;
	return res;
}
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
	int N = B.size();
	return(Solve(B) + Solve(T) + Solve(G) - Solve2(B, T) - Solve2(B, G) - Solve2(T, G)
			+Solve3(B, T, G));
}

Compilation message

museum.cpp: In function 'long long int Solve2(const std::vector<int>&, const std::vector<int>&)':
museum.cpp:16:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < A.size(); ++ i)
                  ~~^~~~~~~~~~
museum.cpp: In function 'long long int Solve3(const std::vector<int>&, const std::vector<int>&, const std::vector<int>&)':
museum.cpp:26:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < A.size(); ++ i)
                  ~~^~~~~~~~~~
museum.cpp: In function 'long long int CountSimilarPairs(std::vector<int>, std::vector<int>, std::vector<int>)':
museum.cpp:36:6: warning: unused variable 'N' [-Wunused-variable]
  int N = B.size();
      ^
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4344 KB Output is correct
2 Correct 7 ms 4348 KB Output is correct
3 Correct 7 ms 4344 KB Output is correct
4 Correct 7 ms 4344 KB Output is correct
5 Correct 7 ms 4472 KB Output is correct
6 Correct 7 ms 4472 KB Output is correct
7 Correct 7 ms 4344 KB Output is correct
8 Correct 8 ms 4472 KB Output is correct
9 Correct 9 ms 4444 KB Output is correct
10 Correct 8 ms 4472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4344 KB Output is correct
2 Correct 7 ms 4348 KB Output is correct
3 Correct 7 ms 4344 KB Output is correct
4 Correct 7 ms 4344 KB Output is correct
5 Correct 7 ms 4472 KB Output is correct
6 Correct 7 ms 4472 KB Output is correct
7 Correct 7 ms 4344 KB Output is correct
8 Correct 8 ms 4472 KB Output is correct
9 Correct 9 ms 4444 KB Output is correct
10 Correct 8 ms 4472 KB Output is correct
11 Correct 9 ms 4600 KB Output is correct
12 Correct 17 ms 5368 KB Output is correct
13 Correct 28 ms 6388 KB Output is correct
14 Correct 38 ms 7140 KB Output is correct
15 Correct 53 ms 8424 KB Output is correct
16 Correct 74 ms 10336 KB Output is correct
17 Correct 77 ms 10484 KB Output is correct
18 Correct 80 ms 10864 KB Output is correct
19 Correct 83 ms 10856 KB Output is correct
20 Correct 83 ms 10892 KB Output is correct