Submission #148420

# Submission time Handle Problem Language Result Execution time Memory
148420 2019-09-01T04:21:03 Z 서울대학교 연구공원 944동 삼성전자서울대연구소(#3600, ho94949, dotorya, zigui) FunctionCup Museum (FXCUP4_museum) C++17
100 / 100
217 ms 11364 KB
#include "museum.h"

#include<bits/stdc++.h>
using namespace std;

template<typename T>
long long s(vector<T> V)
{
	sort(V.begin(), V.end());
	int N = V.size();
	long long ans = 0;
	int cnt = 1;
	for(int i=1; i<N; ++i)
	{
		if(V[i] == V[i-1]) ++cnt;
		else
		{
			ans += 1LL*cnt*(cnt-1)/2;
			cnt = 1;
		}
	}
	return ans + 1LL*cnt*(cnt-1)/2;
}

long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
	int N = B.size();
	
	vector<tuple<int, int, int>> V;
	for(int i=0; i<N; ++i)
		V.emplace_back(B[i], T[i], G[i]);

	vector<pair<int, int> > X;

	long long os = s(B) + s(T) + s(G);

	X.clear();
	for(int i=0; i<N; ++i)
		X.emplace_back(B[i], T[i]);

	os -= s(X);

	X.clear();
	for(int i=0; i<N; ++i)
		X.emplace_back(G[i], T[i]);
	
	os -= s(X);

	X.clear();
	for(int i=0; i<N; ++i)
		X.emplace_back(B[i], G[i]);
	
	os -= s(X);

	os += s(V);
	return os;
}
# Verdict Execution time Memory Grader output
1 Correct 5 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 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 8 ms 512 KB Output is correct
9 Correct 8 ms 512 KB Output is correct
10 Correct 7 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 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 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 8 ms 512 KB Output is correct
9 Correct 8 ms 512 KB Output is correct
10 Correct 7 ms 512 KB Output is correct
11 Correct 11 ms 640 KB Output is correct
12 Correct 27 ms 2172 KB Output is correct
13 Correct 64 ms 4004 KB Output is correct
14 Correct 93 ms 4848 KB Output is correct
15 Correct 138 ms 8120 KB Output is correct
16 Correct 116 ms 11224 KB Output is correct
17 Correct 171 ms 11364 KB Output is correct
18 Correct 205 ms 11364 KB Output is correct
19 Correct 217 ms 11224 KB Output is correct
20 Correct 214 ms 11352 KB Output is correct