#P10833. [COTS 2023] 下 Niz
[COTS 2023] 下 Niz
Background
Translated from Izborne Pripreme 2023 (Croatian IOI/CEOI Team Selection) D2T2。。
Happy birthday to NaCly_Fish!(2024.7.28)。
Problem Description
Given a sequence of length , find the number of pairs that satisfy the following conditions:
- ;
- is a permutation of 。
Input Format
The first line contains a positive integer , representing the length of the sequence.
The second line contains positive integers describing the sequence 。
Output Format
Output one integer in a single line, the number of pairs that satisfy the conditions.
3
3 1 2
3
5
3 2 1 2 3
5
7
2 1 3 1 2 3 4
8
Hint
Sample Explanation
Explanation for Sample : the pairs that satisfy the conditions are 。
Constraints
For of the testdata, it is guaranteed that:
- ;
- 。
| Subtask ID | Score | Constraints |
|---|---|---|
| Each number appears exactly once in the sequence. | ||
| No additional constraints. |
Translated by ChatGPT 5