Submission #764132

# Submission time Handle Problem Language Result Execution time Memory
764132 2023-06-23T07:36:27 Z idkhandle FunctionCup Museum (FXCUP4_museum) C++17
100 / 100
217 ms 18052 KB
#include "museum.h"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

ll CountSimilarPairs(vector<int> B, vector<int> T, vector<int> G) {
	int n = B.size();

	auto add1 = [](vector<int>& x) -> ll {
		map<int, int> one;
		for (int i = 0; i < x.size(); i++) {
			one[x[i]]++;
		}
		ll ret = 0;
		for (auto& [i, j] : one) {
			ret += (ll)j * (j - 1) / 2;
		}
		return ret;
	};
	auto add2 = [](vector<int>& x, vector<int>& y) -> ll {
		map<pair<int, int>, int> two;
		for (int i = 0; i < x.size(); i++) {
			two[pair<int, int>(x[i], y[i])]++;
		}
		ll ret = 0;
		for (auto& [i, j] : two) {
			ret += (ll)j * (j - 1) / 2;
		}
		return ret;
	};
	auto add3 = [](vector<int>& x, vector<int>& y, vector<int>& z) -> ll {
		map<tuple<int, int, int>, int> three;
		for (int i = 0; i < x.size(); i++) {
			three[tuple<int, int, int>(x[i], y[i], z[i])]++;
		}
		ll ret = 0;
		for (auto& [i, j] : three) {
			ret += (ll)j * (j - 1) / 2;
		}
		return ret;
	};
	
	return add1(B) + add1(T) + add1(G) - add2(B, T) - add2(T, G) - add2(G, B) + add3(B, T, G);
}

Compilation message

museum.cpp: In lambda function:
museum.cpp:12:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |   for (int i = 0; i < x.size(); i++) {
      |                   ~~^~~~~~~~~~
museum.cpp: In lambda function:
museum.cpp:23:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   for (int i = 0; i < x.size(); i++) {
      |                   ~~^~~~~~~~~~
museum.cpp: In lambda function:
museum.cpp:34:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   for (int i = 0; i < x.size(); i++) {
      |                   ~~^~~~~~~~~~
museum.cpp: In function 'll CountSimilarPairs(std::vector<int>, std::vector<int>, std::vector<int>)':
museum.cpp:8:6: warning: unused variable 'n' [-Wunused-variable]
    8 |  int n = B.size();
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 6 ms 724 KB Output is correct
12 Correct 10 ms 980 KB Output is correct
13 Correct 53 ms 5420 KB Output is correct
14 Correct 88 ms 7900 KB Output is correct
15 Correct 124 ms 11444 KB Output is correct
16 Correct 43 ms 6244 KB Output is correct
17 Correct 83 ms 6296 KB Output is correct
18 Correct 154 ms 12816 KB Output is correct
19 Correct 217 ms 18008 KB Output is correct
20 Correct 211 ms 18052 KB Output is correct