Submission #148452

# Submission time Handle Problem Language Result Execution time Memory
148452 2019-09-01T04:26:17 Z TeamSUA(#3565, zimpha, sfiction, JTJL) FunctionCup Museum (FXCUP4_museum) C++17
100 / 100
86 ms 9196 KB
#include "museum.h"
#include <bits/stdc++.h>
using namespace std;

long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
	int n = B.size();
	typedef long long ll;
	ll ans = 0;
	vector<int> f[7];
	for (int i = 0; i < 3; i++) {
		f[i].assign(100, 0);
	}
	for (int i = 3; i < 6; i++) {
		f[i].assign(10000, 0);
	}
	for (int i = 6; i < 7; i++) {
		f[i].assign(1000000, 0);
	}
	for (int i = 0; i < n; i++) {
		int p = B[i] - 1, q = T[i] - 1, r = G[i] - 1;
		f[0][p]++, f[1][q]++, f[2][r]++;
		int pq = p * 100 + q, pr = p * 100 + r, qr = q * 100 + r;
		int pqr = p * 10000 + q * 100 + r;
		f[3][pq]++, f[4][pr]++, f[5][qr]++;
		f[6][pqr]++;
	}
	for (int i = 0; i < 3; i++) {
		for (auto &x : f[i])
			ans += 1ll * x * (x - 1) / 2;
	}
	for (int i = 3; i < 6; i++) {
		for (auto &x : f[i])
			ans -= 1ll * x * (x - 1) / 2;
	}
	for (int i = 6; i < 7; i++) {
		for (auto &x : f[i])
			ans += 1ll * x * (x - 1) / 2;
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 4480 KB Output is correct
2 Correct 9 ms 4480 KB Output is correct
3 Correct 10 ms 4352 KB Output is correct
4 Correct 10 ms 4480 KB Output is correct
5 Correct 10 ms 4400 KB Output is correct
6 Correct 11 ms 4480 KB Output is correct
7 Correct 10 ms 4480 KB Output is correct
8 Correct 10 ms 4228 KB Output is correct
9 Correct 11 ms 4480 KB Output is correct
10 Correct 10 ms 4480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 4480 KB Output is correct
2 Correct 9 ms 4480 KB Output is correct
3 Correct 10 ms 4352 KB Output is correct
4 Correct 10 ms 4480 KB Output is correct
5 Correct 10 ms 4400 KB Output is correct
6 Correct 11 ms 4480 KB Output is correct
7 Correct 10 ms 4480 KB Output is correct
8 Correct 10 ms 4228 KB Output is correct
9 Correct 11 ms 4480 KB Output is correct
10 Correct 10 ms 4480 KB Output is correct
11 Correct 11 ms 4480 KB Output is correct
12 Correct 20 ms 5120 KB Output is correct
13 Correct 31 ms 5780 KB Output is correct
14 Correct 39 ms 6392 KB Output is correct
15 Correct 58 ms 7280 KB Output is correct
16 Correct 76 ms 9196 KB Output is correct
17 Correct 79 ms 9068 KB Output is correct
18 Correct 80 ms 9188 KB Output is correct
19 Correct 81 ms 9192 KB Output is correct
20 Correct 86 ms 9068 KB Output is correct