Submission #149175

# Submission time Handle Problem Language Result Execution time Memory
149175 2019-09-01T05:53:28 Z 요까할 로뭘 은명팀(#3558, mario05092929, foja001, earthk) FunctionCup Museum (FXCUP4_museum) C++17
100 / 100
137 ms 46824 KB
#include "museum.h"
#include <bits/stdc++.h>
using namespace std;
int n;
long long cnt[105],cnt2[30005],cnt3[5000005];

long long da1(vector <int> xx)
{
    long long ans = 0;
    for(int i : xx) cnt[i]++;
    for(int i = 1;i <= 100;i++) ans += cnt[i]*(cnt[i]-1)/2;
    memset(cnt,0,sizeof(cnt));
    return ans;
}

long long da2(vector <int> xx,vector <int> yy)
{
    long long ans = 0;
    for(int i = 0;i < n;i++) cnt2[xx[i]*200+yy[i]]++;
    for(int i = 1;i <= 30000;i++) ans += cnt2[i]*(cnt2[i]-1)/2;
    memset(cnt2,0,sizeof(cnt2));
    return ans;
}

long long da3(vector <int> xx,vector <int> yy,vector <int> zz)
{
    long long ans = 0;
    for(int i = 0;i < n;i++) cnt3[xx[i]*40000+yy[i]*200+zz[i]]++;
    for(int i = 1;i <= 5000000;i++) ans += cnt3[i]*(cnt3[i]-1)/2;
    memset(cnt3,0,sizeof(cnt3));
    return ans;
}

long long CountSimilarPairs(vector<int> a1,vector<int> a2,vector<int> a3) {
    long long ans = 0;
    n = a1.size();
    ans = da1(a1)+da1(a2)+da1(a3);
    ans -= da2(a1,a2)+da2(a2,a3)+da2(a3,a1);
    ans += da3(a1,a2,a3);
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 39 ms 39728 KB Output is correct
2 Correct 37 ms 39800 KB Output is correct
3 Correct 38 ms 39536 KB Output is correct
4 Correct 37 ms 39804 KB Output is correct
5 Correct 41 ms 39808 KB Output is correct
6 Correct 38 ms 39800 KB Output is correct
7 Correct 41 ms 39808 KB Output is correct
8 Correct 40 ms 39800 KB Output is correct
9 Correct 41 ms 39800 KB Output is correct
10 Correct 38 ms 39808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 39728 KB Output is correct
2 Correct 37 ms 39800 KB Output is correct
3 Correct 38 ms 39536 KB Output is correct
4 Correct 37 ms 39804 KB Output is correct
5 Correct 41 ms 39808 KB Output is correct
6 Correct 38 ms 39800 KB Output is correct
7 Correct 41 ms 39808 KB Output is correct
8 Correct 40 ms 39800 KB Output is correct
9 Correct 41 ms 39800 KB Output is correct
10 Correct 38 ms 39808 KB Output is correct
11 Correct 42 ms 40052 KB Output is correct
12 Correct 52 ms 40740 KB Output is correct
13 Correct 68 ms 41672 KB Output is correct
14 Correct 80 ms 42668 KB Output is correct
15 Correct 94 ms 44144 KB Output is correct
16 Correct 121 ms 46816 KB Output is correct
17 Correct 126 ms 46824 KB Output is correct
18 Correct 131 ms 46816 KB Output is correct
19 Correct 133 ms 46824 KB Output is correct
20 Correct 137 ms 46684 KB Output is correct