#4313. Distinct Trio

0

Distinct Trio

Distinct Trio

题目描述

You are given a sequence of length NN: A=(A1,A2,…,AN)A=(A_1,A_2,\ldots,A_N).
找到满足下列两个条件的三元组 (i,j,k)(i,j,k) 的个数。

1≤i<j<k≤N1\leq i \lt j \lt k \leq N AiA_i、AjA_j 和 AkA_k 两两互不相同。

输入格式

Input is given from Standard Input in the following format: NN A1A_1 A2A_2 …\ldots ANA_N

输出格式

Print the answer.

4
3 1 4 1
2
10
99999 99998 99997 99996 99995 99994 99993 99992 99991 99990
120
15
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9
355

提示

3≤N≤2×1053 \leq N \leq 2\times 10^5 1≤Ai≤2×1051 \leq A_i \leq 2\times 10^5 输入中的所有数值均为整数。The two triples (i,j,k)(i,j,k) satisfying the conditions are (1,2,3)(1,2,3) and (1,3,4)(1,3,4).

标签: AtCoder|abc252D

来源

AtCoder|abc252D