답안 #148388

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148388 2019-09-01T04:15:41 Z USA1(#3634, ecnerwala, scott_wu, ksun48) 함수컵 박물관 (FXCUP4_museum) C++17
100 / 100
392 ms 25840 KB
#include "museum.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll s1(vector<int> A){
	map<int, ll> freq;
	for(int x : A){
		freq[x]++;
	}
	ll ans = 0;
	for(auto r : freq){
		ans += r.second * r.second;
	}
	return ans;
}

ll s2(vector<int> A, vector<int> B){
	map<int, ll> freq;
	for(int i = 0; i < (int)A.size(); i++){
		freq[A[i] + B[i] * 200]++;
	}
	ll ans = 0;
	for(auto r : freq){
		ans += r.second * r.second;
	}
	return ans;
}

ll s3(vector<int> A, vector<int> B, vector<int> C){
	map<int, ll> freq;
	for(int i = 0; i < (int)A.size(); i++){
		freq[A[i] + B[i] * 200 + C[i] * 40000]++;
	}
	ll ans = 0;
	for(auto r : freq){
		ans += r.second * r.second;
	}
	return ans;
}


long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
	using namespace std;
	ll ans = s1(B) + s1(T) + s1(G) - s2(B, T) - s2(B, G) - s2(T, G) + s3(B, T, G);
	return (ans - (int)B.size()) / 2;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 256 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 7 ms 512 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Correct 8 ms 512 KB Output is correct
9 Correct 9 ms 512 KB Output is correct
10 Correct 9 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 256 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 7 ms 512 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Correct 8 ms 512 KB Output is correct
9 Correct 9 ms 512 KB Output is correct
10 Correct 9 ms 640 KB Output is correct
11 Correct 15 ms 1152 KB Output is correct
12 Correct 22 ms 2560 KB Output is correct
13 Correct 92 ms 7668 KB Output is correct
14 Correct 132 ms 11108 KB Output is correct
15 Correct 223 ms 16368 KB Output is correct
16 Correct 88 ms 14692 KB Output is correct
17 Correct 181 ms 14700 KB Output is correct
18 Correct 282 ms 20832 KB Output is correct
19 Correct 392 ms 25840 KB Output is correct
20 Correct 384 ms 25824 KB Output is correct