Submission #151458

# Submission time Handle Problem Language Result Execution time Memory
151458 2019-09-03T09:18:17 Z AlexPop28 FunctionCup Museum (FXCUP4_museum) C++17
100 / 100
321 ms 16788 KB
#include <bits/stdc++.h>
#include "museum.h"

using namespace std;

const int BASE = 101;

long long Count(const vector<int> &v) {
  map<int, int> freq;
  for (auto &x : v) ++freq[x];
  long long ans = 0LL;
  for (auto &p : freq) ans += 1LL * p.second * (p.second - 1) / 2LL;
  return ans;
}

vector<int> Make(const vector<int> &a, const vector<int> &b) {
  vector<int> ret(a.size());
  for (int i = 0; i < (int)a.size(); ++i) {
    ret[i] = a[i] * BASE + b[i];
  }
  return ret;
}

long long CountSimilarPairs(vector<int> B, vector<int> T, vector<int> G) {
  long long ans = 0LL;
  ans += Count(B);
  ans += Count(T);
  ans += Count(G);
  ans -= Count(Make(B, T));
  ans -= Count(Make(B, G));
  ans -= Count(Make(T, G));
  ans += Count(Make(Make(B, T), G));
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 308 KB Output is correct
7 Correct 3 ms 380 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 5 ms 504 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 308 KB Output is correct
7 Correct 3 ms 380 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 5 ms 504 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
11 Correct 9 ms 760 KB Output is correct
12 Correct 16 ms 1528 KB Output is correct
13 Correct 80 ms 5104 KB Output is correct
14 Correct 124 ms 7276 KB Output is correct
15 Correct 204 ms 10752 KB Output is correct
16 Correct 73 ms 7756 KB Output is correct
17 Correct 123 ms 7896 KB Output is correct
18 Correct 235 ms 13012 KB Output is correct
19 Correct 321 ms 16788 KB Output is correct
20 Correct 313 ms 16788 KB Output is correct