Submission #148887

#TimeUsernameProblemLanguageResultExecution timeMemory
148887채원♡예나 (#200)FunctionCup Museum (FXCUP4_museum)C++17
100 / 100
110 ms13292 KiB
#include "museum.h" #include <cstdio> #include <iostream> #include <string> #include<math.h> #include<algorithm> #include<vector> #include<queue> #include<stack> #include<map> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<int, pii> piii; typedef pair<ll, ll> pll; const int INF = 1e9 + 7; const int MAX = 4005; long long CountSimilarPairs(std::vector<int> a, std::vector<int> b, std::vector<int> c) { int n = a.size(); ll x[101] = { 0 }, y[101] = { 0 }, z[101] = { 0 }; ll xy[10001] = { 0 }, yz[10001] = { 0 }, zx[10001] = { 0 }; ll xyz[1000001] = { 0 }; for (int i = 0; i < n; i++) { int aa, bb, cc; aa = a[i]-1; bb = b[i]-1; cc = c[i]-1; x[aa] ++; y[bb] ++; z[cc] ++; xy[aa * 100 + bb] ++; yz[bb * 100 + cc] ++; zx[cc * 100 + aa] ++; xyz[aa * 10000 + bb * 100 + cc] ++; } ll ans = 0; for (int i = 0; i < 100; i++) { ans += x[i] * (x[i] - 1) / 2; ans += y[i] * (y[i] - 1) / 2; ans += z[i] * (z[i] - 1) / 2; } for (int i = 0; i < 10000; i++) { ans -= xy[i] * (xy[i] - 1) / 2; ans -= yz[i] * (yz[i] - 1) / 2; ans -= zx[i] * (zx[i] - 1) / 2; } for (int i = 0; i < 1000000; i++) { ans += xyz[i] * (xyz[i] - 1) / 2; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...