답안 #148401

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148401 2019-09-01T04:18:03 Z 욱방켜!! (twitch.tv/wookje)(#3584, kig9981, cheetose, jh05013) 함수컵 박물관 (FXCUP4_museum) C++17
100 / 100
468 ms 18288 KB
#include "museum.h"
#include <map>
using namespace std;
typedef long long ll;
const int MX = 101;

ll BC[MX], TC[MX], GC[MX];
map<pair<int, int>, ll> BT, BG, TG;
map<tuple<int, int, int>, ll> BTG;

long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
	int N = B.size();
	long long ans = 0;
	for(int i=0; i<N; i++){
		int b = B[i], t = T[i], g = G[i];
		BC[b]++, TC[t]++, GC[g]++;
		BT[{b,t}]++, BG[{b,g}]++, TG[{t,g}]++;
		BTG[{b,t,g}]++;
	}
	for(int i=0; i<MX; i++){
		ans+= BC[i] * (BC[i]-1);
		ans+= TC[i] * (TC[i]-1);
		ans+= GC[i] * (GC[i]-1);
	}
	for(auto [p,cnt]: BT) ans-= cnt*(cnt-1);
	for(auto [p,cnt]: BG) ans-= cnt*(cnt-1);
	for(auto [p,cnt]: TG) ans-= cnt*(cnt-1);
	for(auto [p,cnt]: BTG) ans+= cnt*(cnt-1);
	return ans/2;
}

Compilation message

museum.cpp: In function 'long long int CountSimilarPairs(std::vector<int>, std::vector<int>, std::vector<int>)':
museum.cpp:25:17: warning: unused variable 'p' [-Wunused-variable]
  for(auto [p,cnt]: BT) ans-= cnt*(cnt-1);
                 ^
museum.cpp:26:17: warning: unused variable 'p' [-Wunused-variable]
  for(auto [p,cnt]: BG) ans-= cnt*(cnt-1);
                 ^
museum.cpp:27:17: warning: unused variable 'p' [-Wunused-variable]
  for(auto [p,cnt]: TG) ans-= cnt*(cnt-1);
                 ^
museum.cpp:28:17: warning: unused variable 'p' [-Wunused-variable]
  for(auto [p,cnt]: BTG) ans+= cnt*(cnt-1);
                 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 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 512 KB Output is correct
6 Correct 7 ms 640 KB Output is correct
7 Correct 7 ms 640 KB Output is correct
8 Correct 7 ms 512 KB Output is correct
9 Correct 10 ms 768 KB Output is correct
10 Correct 9 ms 896 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 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 7 ms 640 KB Output is correct
7 Correct 7 ms 640 KB Output is correct
8 Correct 7 ms 512 KB Output is correct
9 Correct 10 ms 768 KB Output is correct
10 Correct 9 ms 896 KB Output is correct
11 Correct 15 ms 1664 KB Output is correct
12 Correct 21 ms 920 KB Output is correct
13 Correct 106 ms 6592 KB Output is correct
14 Correct 167 ms 9072 KB Output is correct
15 Correct 253 ms 12392 KB Output is correct
16 Correct 76 ms 5096 KB Output is correct
17 Correct 124 ms 5120 KB Output is correct
18 Correct 300 ms 11752 KB Output is correct
19 Correct 468 ms 18288 KB Output is correct
20 Correct 458 ms 18276 KB Output is correct