답안 #148727

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148727 2019-09-01T05:00:19 Z White Fairy(#3613, wifi) 함수컵 박물관 (FXCUP4_museum) C++17
100 / 100
241 ms 19260 KB
#include "museum.h"
#include <bits/stdc++.h>

using namespace std;


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

template<typename T>
long long calc2(vector<T> A, vector<T> B) {
  vector<pair<T, T>> v(A.size());
  for (int i = 0; i < (int)v.size(); ++i)
    v[i] = {A[i], B[i]};
  return calc(v);
}

template<typename T>
long long calc3(vector<T> A, vector<T> B, vector<T> C) {
  vector<tuple<T, T, T>> v(A.size());
  for (int i = 0; i < (int)v.size(); ++i)
    v[i] = {A[i], B[i], C[i]};
  return calc(v);
}

long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
	return calc(B) + calc(T) + calc(G) - calc2(B, T) - calc2(B, G) - calc2(T, G) + calc3(B, T, G);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 344 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Correct 7 ms 512 KB Output is correct
9 Correct 7 ms 512 KB Output is correct
10 Correct 7 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 344 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 7 ms 512 KB Output is correct
8 Correct 7 ms 512 KB Output is correct
9 Correct 7 ms 512 KB Output is correct
10 Correct 7 ms 512 KB Output is correct
11 Correct 11 ms 896 KB Output is correct
12 Correct 26 ms 3376 KB Output is correct
13 Correct 63 ms 5572 KB Output is correct
14 Correct 100 ms 8048 KB Output is correct
15 Correct 138 ms 11972 KB Output is correct
16 Correct 123 ms 19260 KB Output is correct
17 Correct 184 ms 19260 KB Output is correct
18 Correct 219 ms 19136 KB Output is correct
19 Correct 241 ms 19260 KB Output is correct
20 Correct 222 ms 19256 KB Output is correct