답안 #149160

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149160 2019-09-01T05:51:14 Z 요까할 로뭘 은명팀(#3558, mario05092929, foja001, earthk) 함수컵 박물관 (FXCUP4_museum) C++17
0 / 100
6 ms 640 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++) cnt2[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;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -