#include <bits/stdc++.h>
#define L long long
using namespace std;
int n;
int a[7][200020];
L cnt[1000010];
L CountSimilarPairs(vector<int>B, vector<int>T, vector<int> G){
int i,j;
L ret=0;
n=B.size();
for(i=0;i<n;i++)
{
B[i]--;
T[i]--;
G[i]--;
a[0][i]=B[i];
a[1][i]=T[i];
a[2][i]=G[i];
a[3][i]=B[i]*10000+T[i]*100+G[i];
a[4][i]=B[i]*100+T[i];
a[5][i]=T[i]*100+G[i];
a[6][i]=G[i]*100+B[i];
}
for(i=0;i<7;i++)
{
for(j=0;j<n;j++)
{
if(i<=3) ret+=cnt[a[i][j]];
else ret-=cnt[a[i][j]];
cnt[a[i][j]]++;
}
for(j=0;j<n;j++)
{
cnt[a[i][j]]--;
}
}
return ret;
}
/*
#include <stdio.h>
#include <stdlib.h>
#include "museum.h"
static int N;
static std::vector<int> Badge, Tshirt, Gift;
static void my_assert(int TF, const char* message){
if(!TF){ puts(message); exit(1); }
}
int main(){
my_assert(scanf("%d", &N) == 1, "Error: Invalid Input");
my_assert(2 <= N && N <= 200000, "Error: Invalid Input");
for(int i=0; i<N; i++){
int a;
my_assert(scanf("%d", &a) == 1, "Error: Invalid Input");
my_assert(1 <= a && a <= 100, "Error: Invalid Input");
Badge.push_back(a);
}
for(int i=0; i<N; i++){
int a;
my_assert(scanf("%d", &a) == 1, "Error: Invalid Input");
my_assert(1 <= a && a <= 100, "Error: Invalid Input");
Tshirt.push_back(a);
}
for(int i=0; i<N; i++){
int a;
my_assert(scanf("%d", &a) == 1, "Error: Invalid Input");
my_assert(1 <= a && a <= 100, "Error: Invalid Input");
Gift.push_back(a);
}
printf("%lld\n", CountSimilarPairs(Badge, Tshirt, Gift));
return 0;
}
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
512 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
6 ms |
768 KB |
Output is correct |
5 |
Correct |
6 ms |
1708 KB |
Output is correct |
6 |
Correct |
7 ms |
2816 KB |
Output is correct |
7 |
Correct |
8 ms |
3584 KB |
Output is correct |
8 |
Correct |
6 ms |
640 KB |
Output is correct |
9 |
Correct |
10 ms |
5632 KB |
Output is correct |
10 |
Correct |
10 ms |
5632 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
512 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
6 ms |
768 KB |
Output is correct |
5 |
Correct |
6 ms |
1708 KB |
Output is correct |
6 |
Correct |
7 ms |
2816 KB |
Output is correct |
7 |
Correct |
8 ms |
3584 KB |
Output is correct |
8 |
Correct |
6 ms |
640 KB |
Output is correct |
9 |
Correct |
10 ms |
5632 KB |
Output is correct |
10 |
Correct |
10 ms |
5632 KB |
Output is correct |
11 |
Correct |
13 ms |
8064 KB |
Output is correct |
12 |
Correct |
19 ms |
2048 KB |
Output is correct |
13 |
Correct |
37 ms |
10108 KB |
Output is correct |
14 |
Correct |
51 ms |
12528 KB |
Output is correct |
15 |
Correct |
70 ms |
14704 KB |
Output is correct |
16 |
Correct |
91 ms |
10732 KB |
Output is correct |
17 |
Correct |
94 ms |
10848 KB |
Output is correct |
18 |
Correct |
103 ms |
12896 KB |
Output is correct |
19 |
Correct |
110 ms |
18564 KB |
Output is correct |
20 |
Correct |
106 ms |
18532 KB |
Output is correct |