Submission #148591

# Submission time Handle Problem Language Result Execution time Memory
148591 2019-09-01T04:43:53 Z koosaga fan club(#3590, xiaowuc1) FunctionCup Museum (FXCUP4_museum) C++17
100 / 100
552 ms 18404 KB
#include <bits/stdc++.h>
#include "museum.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;

long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
	map<int, ll> b, t, g;
	map<pii, ll> bt, bg, tg;
	map<pipii, ll> btg;
	int n = B.size();
	ll ret = 0;
	for(int i = 0; i < B.size(); i++) {
		b[B[i]]++;
		t[T[i]]++;
		g[G[i]]++;
		bt[{B[i], T[i]}]++;
		bg[{B[i], G[i]}]++;
		tg[{T[i], G[i]}]++;
		btg[{B[i], {T[i], G[i]}}]++;
	}
	for(auto out: b) ret += out.second * (out.second-1) / 2;
	for(auto out: t) ret += out.second * (out.second-1) / 2;
	for(auto out: g) ret += out.second * (out.second-1) / 2;
	for(auto out: bt) ret -= out.second * (out.second-1) / 2;
	for(auto out: bg) ret -= out.second * (out.second-1) / 2;
	for(auto out: tg) ret -= out.second * (out.second-1) / 2;
	for(auto out: btg) ret += out.second * (out.second-1) / 2;
	return ret;
}

Compilation message

museum.cpp: In function 'long long int CountSimilarPairs(std::vector<int>, std::vector<int>, std::vector<int>)':
museum.cpp:16:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < B.size(); i++) {
                 ~~^~~~~~~~~~
museum.cpp:14:6: warning: unused variable 'n' [-Wunused-variable]
  int n = B.size();
      ^
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 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 768 KB Output is correct
7 Correct 7 ms 640 KB Output is correct
8 Correct 8 ms 512 KB Output is correct
9 Correct 10 ms 896 KB Output is correct
10 Correct 9 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 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 768 KB Output is correct
7 Correct 7 ms 640 KB Output is correct
8 Correct 8 ms 512 KB Output is correct
9 Correct 10 ms 896 KB Output is correct
10 Correct 9 ms 896 KB Output is correct
11 Correct 17 ms 1664 KB Output is correct
12 Correct 20 ms 1152 KB Output is correct
13 Correct 118 ms 6644 KB Output is correct
14 Correct 208 ms 9072 KB Output is correct
15 Correct 307 ms 12400 KB Output is correct
16 Correct 81 ms 5228 KB Output is correct
17 Correct 151 ms 5232 KB Output is correct
18 Correct 372 ms 11872 KB Output is correct
19 Correct 552 ms 18276 KB Output is correct
20 Correct 504 ms 18404 KB Output is correct