답안 #148362

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148362 2019-09-01T04:07:46 Z 잉여로운 고3(#3749, imyujin, sebinkim) 함수컵 박물관 (FXCUP4_museum) C++17
100 / 100
107 ms 13292 KB
#include <bits/stdc++.h>

#include "museum.h"

using namespace std;

typedef long long ll;

ll X1[111], X2[111], X3[111];
ll Y1[10101], Y2[10101], Y3[10101];
ll Z[1010101];
ll n, ans;

ll CountSimilarPairs(vector <int> B, vector <int> T, vector <int> G)
{
	ll i;
	
	n = B.size();
	
	for(i=0; i<n; i++){
		B[i] --; T[i] --; G[i] --;
		X1[B[i]] ++; X2[T[i]] ++; X3[G[i]] ++;
		Y1[B[i] * 100 + T[i]] ++; Y2[T[i] * 100 + G[i]] ++; Y3[G[i] * 100 + B[i]] ++;
		Z[B[i] * 10000 + T[i] * 100 + G[i]] ++;
	}
	
	for(i=0; i<100; i++){
		ans += X1[i] * (X1[i] - 1) / 2;
		ans += X2[i] * (X2[i] - 1) / 2;
		ans += X3[i] * (X3[i] - 1) / 2;
	}
	
	for(i=0; i<10000; i++){
		ans -= Y1[i] * (Y1[i] - 1) / 2;
		ans -= Y2[i] * (Y2[i] - 1) / 2;
		ans -= Y3[i] * (Y3[i] - 1) / 2;
	}
	
	for(i=0; i<1e6; i++){
		ans += Z[i] * (Z[i] - 1) / 2;
	}
	
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 384 KB Output is correct
2 Correct 9 ms 512 KB Output is correct
3 Correct 10 ms 512 KB Output is correct
4 Correct 9 ms 768 KB Output is correct
5 Correct 10 ms 2048 KB Output is correct
6 Correct 10 ms 2944 KB Output is correct
7 Correct 10 ms 3712 KB Output is correct
8 Correct 10 ms 640 KB Output is correct
9 Correct 11 ms 5760 KB Output is correct
10 Correct 12 ms 5760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 384 KB Output is correct
2 Correct 9 ms 512 KB Output is correct
3 Correct 10 ms 512 KB Output is correct
4 Correct 9 ms 768 KB Output is correct
5 Correct 10 ms 2048 KB Output is correct
6 Correct 10 ms 2944 KB Output is correct
7 Correct 10 ms 3712 KB Output is correct
8 Correct 10 ms 640 KB Output is correct
9 Correct 11 ms 5760 KB Output is correct
10 Correct 12 ms 5760 KB Output is correct
11 Correct 14 ms 8192 KB Output is correct
12 Correct 20 ms 1152 KB Output is correct
13 Correct 38 ms 8692 KB Output is correct
14 Correct 51 ms 10480 KB Output is correct
15 Correct 71 ms 11500 KB Output is correct
16 Correct 80 ms 5224 KB Output is correct
17 Correct 80 ms 5356 KB Output is correct
18 Correct 85 ms 7524 KB Output is correct
19 Correct 107 ms 13288 KB Output is correct
20 Correct 107 ms 13292 KB Output is correct