Submission #151971

# Submission time Handle Problem Language Result Execution time Memory
151971 2019-09-05T17:53:29 Z minty99 FunctionCup Museum (FXCUP4_museum) C++17
100 / 100
78 ms 11108 KB
#include "museum.h"
#include <stdio.h>
int B_only[101], T_only[101], G_only[101];
int BT[101][101], BG[101][101], TG[101][101];
int BTG[101][101][101];

long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
	for(int i = 0; i < B.size(); i++)
	{
		int b = B[i], t = T[i], g = G[i];
		B_only[b]++;
		T_only[t]++;
		G_only[g]++;
		BT[b][t]++;
		BG[b][g]++;
		TG[t][g]++;
		BTG[b][t][g]++;
	}

	long long answer = 0;
	for(int i = 0; i < B.size(); i++)
	{
		int b = B[i], t = T[i], g = G[i];
		int nA = B_only[b];
		int nB = T_only[t];
		int nC = G_only[g];
		int nAB = BT[b][t];
		int nAC = BG[b][g];
		int nBC = TG[t][g];
		int nABC = BTG[b][t][g];
		long long ans = (long long) nA + nB + nC - nAB - nBC - nAC + nABC - 1;
		answer += ans;
	}
	return answer / 2;
}

Compilation message

museum.cpp: In function 'long long int CountSimilarPairs(std::vector<int>, std::vector<int>, std::vector<int>)':
museum.cpp:8:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < B.size(); i++)
                 ~~^~~~~~~~~~
museum.cpp:21:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < B.size(); i++)
                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 632 KB Output is correct
5 Correct 3 ms 1656 KB Output is correct
6 Correct 3 ms 2168 KB Output is correct
7 Correct 4 ms 2936 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 6 ms 3960 KB Output is correct
10 Correct 6 ms 3832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 632 KB Output is correct
5 Correct 3 ms 1656 KB Output is correct
6 Correct 3 ms 2168 KB Output is correct
7 Correct 4 ms 2936 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 6 ms 3960 KB Output is correct
10 Correct 6 ms 3832 KB Output is correct
11 Correct 7 ms 4600 KB Output is correct
12 Correct 11 ms 1272 KB Output is correct
13 Correct 25 ms 5976 KB Output is correct
14 Correct 35 ms 7152 KB Output is correct
15 Correct 49 ms 8552 KB Output is correct
16 Correct 64 ms 6352 KB Output is correct
17 Correct 67 ms 6508 KB Output is correct
18 Correct 74 ms 8016 KB Output is correct
19 Correct 77 ms 10980 KB Output is correct
20 Correct 78 ms 11108 KB Output is correct