답안 #149551

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149551 2019-09-01T06:42:52 Z (παρα)γεμιστά(#3619, cfalas, ctziapo, Charis02) 함수컵 박물관 (FXCUP4_museum) C++17
100 / 100
455 ms 21220 KB
#include "museum.h"
#include<map>
#include<vector>
#include<iostream>
#define ll long long
#define rep(i,a,b) for(int i = a;i < b;i++)
#define MAXN 300003

using namespace std;

ll ar[MAXN][3];
map < ll,ll > freq;

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

	ll ans = 0;

    rep(i,0,n)
    {
        ar[i][0] = B[i];
        ar[i][1] = T[i];
        ar[i][2] = G[i];
    }

    // 1 stixio kino

    rep(t,0,3)
    {
        freq.clear();
        rep(i,0,n)
        {
            freq[ar[i][t]]++;
        }

        for(map < ll,ll >::iterator it = freq.begin();it != freq.end();it++)
        {
            ll val = it->second;
            ans += (val*(val-1))/2;
        }
    }

   // cout << ans << endl;
    // 2 stixia kina

    freq.clear();

    rep(i,0,n)
    {
        freq[ar[i][0]*101 + ar[i][1]]++;
    }

    for(map < ll,ll >::iterator it = freq.begin();it != freq.end();it++)
    {
        ll val = it->second;
        ans -= (val*(val-1))/2;
    }

    freq.clear();
    rep(i,0,n)
    {
        freq[ar[i][0]*101 + ar[i][2]]++;
    }

    for(map < ll,ll >::iterator it = freq.begin();it != freq.end();it++)
    {
        ll val = it->second;
        ans -= (val*(val-1))/2;
    }

   // cout << ans << endl;

    freq.clear();

    rep(i,0,n)
    {
        freq[ar[i][1]*101 + ar[i][2]]++;
    }

    for(map < ll,ll >::iterator it = freq.begin();it != freq.end();it++)
    {
        ll val = it->second;
        ans -= (val*(val-1))/2;
    }

    // 3 stixia kina

    freq.clear();

    rep(i,0,n)
    {
        freq[ar[i][0]*12000+ar[i][1]*101+ar[i][2]]++;
    }

    for(map < ll,ll >::iterator it = freq.begin();it != freq.end();it++)
    {
        ll val = it->second;
        ans += (val*(val-1))/2;
    }

	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 472 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 13 ms 512 KB Output is correct
7 Correct 8 ms 512 KB Output is correct
8 Correct 7 ms 512 KB Output is correct
9 Correct 19 ms 640 KB Output is correct
10 Correct 9 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 472 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 13 ms 512 KB Output is correct
7 Correct 8 ms 512 KB Output is correct
8 Correct 7 ms 512 KB Output is correct
9 Correct 19 ms 640 KB Output is correct
10 Correct 9 ms 640 KB Output is correct
11 Correct 17 ms 1024 KB Output is correct
12 Correct 20 ms 1792 KB Output is correct
13 Correct 88 ms 6392 KB Output is correct
14 Correct 153 ms 9096 KB Output is correct
15 Correct 250 ms 13424 KB Output is correct
16 Correct 77 ms 9964 KB Output is correct
17 Correct 144 ms 9964 KB Output is correct
18 Correct 332 ms 16004 KB Output is correct
19 Correct 455 ms 21128 KB Output is correct
20 Correct 413 ms 21220 KB Output is correct