Submission #764132

#TimeUsernameProblemLanguageResultExecution timeMemory
764132idkhandleFunctionCup Museum (FXCUP4_museum)C++17
100 / 100
217 ms18052 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...